summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-07-22 23:35:31 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:47 +0200
commit673f690a37f6673a3262e933709c79de8a66f48c (patch)
tree3acd007863bf23ce8549f9edb5e51d23a3bc6078
parent352e3b3230dfc6746be6d53325ffe1e33efc5289 (diff)
downloaddev86-673f690a37f6673a3262e933709c79de8a66f48c.tar.gz
Import Dev86src-0.16.4.tar.gzv0.16.4
-rw-r--r--Makefile2
-rw-r--r--as/alloc.c10
-rw-r--r--bcc/assign.c2
-rw-r--r--bcc/bcc.bugs169
-rw-r--r--bcc/bcc.c76
-rw-r--r--bcc/declare.c20
-rw-r--r--bcc/patch.file157
-rw-r--r--bcc/proto.h2
-rw-r--r--bcc/q112
-rw-r--r--bcc/scan.h1
-rw-r--r--bcc/table.c3
-rw-r--r--bcc/type.c19
-rw-r--r--bootblocks/Makefile25
-rw-r--r--bootblocks/bb_init1.s25
-rw-r--r--bootblocks/bb_init2.s17
-rw-r--r--bootblocks/bb_linux.s22
-rw-r--r--bootblocks/boot_fpy.s6
-rw-r--r--bootblocks/buffer.c142
-rw-r--r--bootblocks/bzimage.c21
-rw-r--r--bootblocks/com_bcc.s65
-rw-r--r--bootblocks/crc.c216
-rw-r--r--bootblocks/elf_info.c189
-rw-r--r--bootblocks/elf_info.h282
-rw-r--r--bootblocks/i86_funcs.c94
-rw-r--r--bootblocks/i86_funcs.h4
-rw-r--r--bootblocks/li86.s47
-rw-r--r--bootblocks/makeboot.c4
-rw-r--r--bootblocks/mbr.s3
-rw-r--r--bootblocks/min_buf.c119
-rw-r--r--bootblocks/monitor.c17
-rw-r--r--bootblocks/monitor.h15
-rw-r--r--bootblocks/standalone.c310
-rw-r--r--bootblocks/tich.s39
-rw-r--r--bootblocks/trk_buf.c390
-rw-r--r--copt/copt.c4
-rw-r--r--elksemu/elks_sys.c2
-rw-r--r--ld/objdump86.c2
-rw-r--r--libc/bios/Makefile10
-rw-r--r--libc/bios/bios_disk.c158
-rw-r--r--libc/bios/fs_dos.c98
-rw-r--r--libc/bios/rawio.c11
-rw-r--r--libc/include/bios.h1
-rw-r--r--libc/include/ctype.h5
-rw-r--r--libc/include/stdio.h11
-rw-r--r--libc/misc/Makefile2
-rw-r--r--libc/misc/crypt.c4
-rw-r--r--libc/misc/ctype.c14
-rw-r--r--libc/misc/ctypefn.c25
-rw-r--r--libc/stdio/Makefile6
-rw-r--r--libc/stdio/stdio.c34
-rw-r--r--libc/stdio/stdio.h11
-rw-r--r--libc/syscall/syscall.dev8617
-rw-r--r--makefile.in8
-rw-r--r--man/bcc.17
-rw-r--r--tests/Makefile4
-rwxr-xr-xtests/a.outbin0 -> 8783 bytes
-rw-r--r--tests/ft.c6
-rw-r--r--tests/hd.c40
-rw-r--r--tests/size.c83
-rw-r--r--unproto/Makefile2
-rw-r--r--unproto/unproto.c3
61 files changed, 963 insertions, 2230 deletions
diff --git a/Makefile b/Makefile
index 4889298..b0e5113 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
# This file is part of the Linux-8086 Development environment and is
# distributed under the GNU General Public License.
-VERSION=0.16.3
+VERSION=0.16.4
TARGETS= \
clean bcc unproto copt as86 ld86 elksemu \
diff --git a/as/alloc.c b/as/alloc.c
index 6f64ccc..b4e94fc 100644
--- a/as/alloc.c
+++ b/as/alloc.c
@@ -20,12 +20,13 @@ init_heap()
{
#ifdef USE_FIXED_HEAP
#ifndef USERMEM
-#define USERMEM (unsigned) 0xAC00U
+#define USERMEM 0xAC00U
#endif
#ifdef __AS386_16__
+ int stk;
heapptr = sbrk(0);
- heapend = ((char*)&argc) - STAKSIZ - 16;
+ heapend = ((char*)&stk) - STAKSIZ - 16;
brk(heapend);
if(sbrk(0) != heapend)
as_abort(NOMEMEORY);
@@ -68,8 +69,7 @@ unsigned int size;
#else
rv = malloc(size);
#endif
-
- if (rv == 0) as_abort(NOMEMEORY);
+ if (rv == 0 && size) as_abort(NOMEMEORY);
return rv;
}
@@ -85,7 +85,7 @@ unsigned int size;
if ((char*)oldptr+size < heapend)
{
- heapptr = oldptr + size;
+ heapptr = (char*)oldptr + size;
rv = oldptr;
}
else
diff --git a/bcc/assign.c b/bcc/assign.c
index 5f25cc0..2dce7c4 100644
--- a/bcc/assign.c
+++ b/bcc/assign.c
@@ -316,7 +316,7 @@ struct symstruct *target;
extend(target);
load(target, DREG);
target->storage = targreg = getindexreg();
- if (oldscalar & (UNSIGNED | CHAR) ||
+ if (oldscalar & UNSIGNED ||
target->type->constructor & (ARRAY | FUNCTION | POINTER))
uitol(targreg);
else
diff --git a/bcc/bcc.bugs b/bcc/bcc.bugs
deleted file mode 100644
index 52f6958..0000000
--- a/bcc/bcc.bugs
+++ /dev/null
@@ -1,169 +0,0 @@
-compiler limitations
---------------------
-
-These are not implemented:
-
-a. bit fields
- kludgily implemented (everything padded to char, int or long; can store
- values wider than the specified field width)
-
-g. signed char type, other ANSI extensions
-
-compiler bugs
--------------
-
-6. weird but doable casts are not always done for initializers
-
-15. calls to a (casted) absolute address produce an immediate prefix. as386
- doesn't mind this but complains about the absolute address. as09 complains
- about the prefix but can handle the absolute address
-
-23. char *f(); &f() is accepted as f() but produces botched nodetype
- (calc char **).
-
-31. null byte in string initialiser should be ignored if it doesn't fit
- Non-null bytes which don't fit should be ignored with a warning
-
-32. static char c = "xyz"; is allowed, and bad FCB is generated
-
-37. init of union will store multiple comma-separated entries
-
-38. arrays sizes larger than the amount of memory are accepted
-
-40. structure and union definitions are confused with each other. So
- struct foo may be used in a declaration like "union foo bar;"
-
-42. pointer arithmetic is performed on pointers to undefined structures
- (of unknown size). Size is taken as 0 although alignmask is set early
-
-59. preprocessor stuff (# lines or macro names) between the identifier for
- a label and the colon for the label messes up the label
-
-60. some things involving switches are now broken for 6809 due to lack of
- frame pointer
-
-61. assembler may get lost on lines of length exactly (?) 256
-
-65. expressions in emum lists or not properly checked for overflow. They
- should fit in ints. The ordinal number is allowed to overflow
-
-66. sizeof has type int instead of size_t
-
-68. "return expr;" in a function returning a void is reported as a compiler
- bug not as a semantic error
-
-69. an argument declared as float is (correctly) promoted to double, but
- not demoted to float when it is used
-
-71. identifiers longer than 64 are botched (scanning of the identifier is
- stopped but the remaining characters in the identifier are left to
- mess up the input stream
-
-72. check for too many macro parameters is not working
-
-74. union { char a, b; } foo; gives the wrong offset for b. Unions work OK
- if the declaration lists have length 1
-
-75. stack gets cleaned up too early in bee = foo ? bar : baz() where baz()
- returns a struct although there is kludge to make plain bee = baz() work
-
-76. have reintroduced reduced-type bugs, so sizeof(1 ? 1 : 2) is 1
-
-78. fix to require comma in arg list may be half-baked
-
-79. compiler starts trying to load the void expression (i ? (void)0 : (void)0)
-
-80. (unsigned char *) - (char *) causes error and message is obscure
-
-81. 'defined' is a reserved word
-
-82. conditionals with voids don't work
-
-83. float = 1e100 gets overflow exception
-
-84. #endif seems to be seen in
-#if 1
-foo #endif bar
-
-85. line numbers from cpp are not quite right.
-
-bugs that may be fixed
-----------------------
-
-41. typedef's are not scoped properly
-
-nonstandard things that are not done quite right
-------------------------------------------------
-
-3. arguments declared as register are not being dumped by #asm, register
- vars anyway not being passed to #asm
-
-26. should clear label ptrs when starting #asm
-
-things that have to be be done better
--------------------------------------
-
-11. push order reversed in genloads.c (temp) - might try to get DP order right
-
-12. need to clean up handling of sc specs (maybe rename flags to sc)
- And local statics and externs
-
-24. gvarsc is not returned properly for struct/union since the members
- affect gvarsc (incorrectly). There should be a flag set when
- inside a struct/union definition to disable sc specs. This could
- replace the tests in abdeclarator and declselt
- Best may be to carry the sc along with the type a bit more (in a
- global symbol structure). Also, the symbol should record sc in a better
- way than now
-
-25. need to check stack sometimes. Xenix cc does it when allocating >= 100
- bytes locals and this is essential in Xenix as the stack is grown
- dynamically
-
-68. overflow checking for constants
-
-things that could be done better
---------------------------------
-
-4. install new 6809 code for branch patching (after redundancy checks)
-
-5. can improve code for compare with global adr in non-posindependent case
-
-6. char *s; long *pl;
- code for *s += *pl is poor, for *s += (int) *pl is good
-
-7. most mov's from to ax would be faster and smaller done by xchg's
-
-7a. check ptr add/sub operations earlier
-
-8. tests for against 1 and -1 can sometimes be done with dec's and inc's
-
-9. __opreg is used unnec when the ptr is already in it
-
-9a. double indirect ptrs should maybe be made direct rather than singly
- indirect by makelessindirect
-
-10. in cmpsmallconst(), the comparison constant should be incorporated in
- the offset if the indcount is 0 and lea() called. It is harmless to
- use the lea() trick for non-small constants
-
-20. when saved registers are popped in assign() they may overwrite the
- expression value, anywhere else? May be fixed now
-
-27. better if loadexpression returned the register used
-
-28. better if source.c did not #include storage.h - it only references
- DEFINITION, in some blank-skipping code which could be moved to
- scan.c or preproc.c. preproc.c, scan.c and type.c also #include
- storage.h, just to get at the DEFINITION and KEYWORD definitions
-
-29. need nodetype() to know about all optimisations in advance, including
- int % small power of 2 (including 0, 1). Need to delete all type
- assignments in final code gen, specially the one that convert short
- to int
-
-30. overflow checking at runtime
-
-31. Use more than the first char from multiple character constants
-
-56. --i++ is not detected as an error in the parser
diff --git a/bcc/bcc.c b/bcc/bcc.c
index 4717315..36024df 100644
--- a/bcc/bcc.c
+++ b/bcc/bcc.c
@@ -143,6 +143,7 @@ void newfilename P((struct file_list * file, int last_stage, int new_extn, int u
void run_unlink P((void));
void append_file P((char * filename, int ftype));
void append_option P((char * option, int otype));
+void prepend_option P((char * option, int otype));
char * expand_tilde P((char * str));
void * xalloc P((int size));
void Usage P((void));
@@ -182,8 +183,7 @@ char * exec_prefixs[] = {
#endif
"~/lib/",
"~/bin/",
- "/usr/bin/",
- 0
+ 0 /* Last chance is contents of $PATH */
};
char * libc = "-lc";
@@ -397,6 +397,7 @@ struct file_list * file;
command_reset();
newfilename(file, !do_link, 'o', 1);
command_opt("-r");
+ command_opt("-N");
run_command(file);
}
}
@@ -654,7 +655,7 @@ char ** argv;
do_unproto = 1;
opt_e = 1;
/* NOTE I'm setting this to zero, this isn't a _real_ STDC */
- append_option("-D__STDC__=0", 'p');
+ prepend_option("-D__STDC__=0", 'p');
}
else
Usage();
@@ -750,7 +751,7 @@ char ** argv;
do_optim=1;
break;
- case 'G': opt_M = 'G'; break;
+ case 'G': opt_M = 'g'; break;
case 'v': opt_v++; break;
case 'V': opt_V++; break;
@@ -762,8 +763,8 @@ char ** argv;
case 'W': opt_W++; break;
- case '0': opt_arch=0; opt_M='x'; break;
- case '3': opt_arch=1; opt_M='x'; break;
+ case '0': opt_arch=0; break;
+ case '3': opt_arch=1; break;
case 'w': /*IGNORED*/ break;
case 'g': /*IGNORED*/ break;
@@ -809,55 +810,57 @@ char ** argv;
if (opt_M==0) opt_M = (opt_arch==1 ?'l':'n');
switch(opt_M)
{
- case 'n':
- append_option("-D__ELKS__", 'p');
- append_option("-D__unix__", 'p');
+ case 'n': /* Normal Elks */
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__ELKS__", 'p');
libc="-lc";
break;
- case 'f':
- append_option("-D__ELKS__", 'p');
- append_option("-D__unix__", 'p');
+ case 'f': /* Fast Call Elks */
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__ELKS__", 'p');
append_option("-c", 'p');
append_option("-f", 'p');
libc="-lc_f";
break;
- case 'c':
- append_option("-D__ELKS__", 'p');
- append_option("-D__unix__", 'p');
+ case 'c': /* Caller saves Elks */
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__ELKS__", 'p');
append_option("-c", 'p');
libc="-lc";
break;
- case 's':
- append_option("-D__STANDALONE__", 'p');
+ case 's': /* Standalone 8086 */
+ prepend_option("-D__STANDALONE__", 'p');
libc="-lc_s";
break;
- case 'd':
- append_option("-D__MSDOS__", 'p');
+ case 'd': /* DOS COM file */
+ prepend_option("-D__MSDOS__", 'p');
libc="-ldos";
append_option("-d", 'l');
append_option("-T100", 'l');
break;
- case 'l':
+ case 'l': /* 386 Linux a.out */
opt_arch=1;
- append_option("-D__linux__", 'p');
- append_option("-D__unix__", 'p');
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__linux__", 'p');
libc="-lc";
append_option("-N", 'l');
break;
- case 'G':
+ case 'g': /* 386 Linux object using gcc as linker */
opt_arch = 2;
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__linux__", 'p');
break;
- case '8':
+ case '8': /* Use 'c386' program as compiler */
opt_arch = 3;
opt_e = 1;
break;
- case '9':
+ case '9': /* 6809 compiler */
opt_arch = 4;
default_libdir0 = "-L~/lib/bcc/m09/";
optim_rules = "-d~/lib/bcc/m09";
add_prefix("~/lib/bcc/m09/");
break;
- case '0':
+ case '0': /* Plain old Unix V7 style */
opt_arch = 5;
opt_e = 1;
opt_I = 1;
@@ -952,6 +955,20 @@ int otype;
}
}
+void
+prepend_option (option, otype)
+char * option;
+int otype;
+{
+ struct opt_list * newopt = xalloc(sizeof(struct opt_list));
+
+ newopt->opt = copystr(option);
+ newopt->opttype = otype;
+
+ newopt->next = options;
+ options = newopt;
+}
+
char * expand_tilde(str)
char * str;
{
@@ -1039,11 +1056,13 @@ void reset_localprefix()
strcpy(temp, s);
strcat(temp, "/");
strcat(temp, progname);
+#ifndef __BCC__
if( realpath(temp, buf) != 0 )
{
free(temp);
temp = copystr(buf);
}
+#endif
if( access(temp, X_OK) == 0 ) break;
d++;
}
@@ -1119,7 +1138,10 @@ static char ** minienviron[] = {
#ifdef __BCC__
execve(command.fullpath, command.arglist, minienviron);
#else
- execv(command.fullpath, command.arglist);
+ if (command.fullpath[0] =='/')
+ execv(command.fullpath, command.arglist);
+ else
+ execvp(command.fullpath, command.arglist);
#endif
fprintf(stderr, "Unable to execute %s.\n", command.fullpath);
exit(1);
diff --git a/bcc/declare.c b/bcc/declare.c
index 73a8524..40175e6 100644
--- a/bcc/declare.c
+++ b/bcc/declare.c
@@ -412,12 +412,13 @@ ts_s_newtypelist += sizeof *newtypelist;
PRIVATE bool_pt declspec()
{
unsigned nsc;
+ unsigned nsigned;
unsigned ntype;
unsigned nunsigned;
gvarsc = NULLDECL;
gvartype = itype;
- nunsigned = ntype = nsc = 0;
+ nsigned = nunsigned = ntype = nsc = 0;
while (TRUE)
{
switch (sym)
@@ -484,6 +485,10 @@ PRIVATE bool_pt declspec()
gvartype = gsymptr->type;
nextsym();
break;
+ case SIGNDECL:
+ ++nsigned;
+ nextsym();
+ break;
case UNSIGNDECL:
++nunsigned;
nextsym();
@@ -493,6 +498,17 @@ PRIVATE bool_pt declspec()
}
}
break2:
+ if (nsigned > 0)
+ {
+ if (ntype == 0)
+ {
+ gvartype = itype;
+ ntype = 1;
+ }
+ gvartype = tosigned(gvartype);
+ if (nsigned > 1 || nunsigned > 0)
+ ntype = 2;
+ }
if (nunsigned > 0)
{
if (ntype == 0)
@@ -501,7 +517,7 @@ break2:
ntype = 1;
}
gvartype = tounsigned(gvartype);
- if (nunsigned > 1)
+ if (nunsigned > 1 || nsigned > 0)
ntype = 2;
}
if (nsc > 0)
diff --git a/bcc/patch.file b/bcc/patch.file
new file mode 100644
index 0000000..20a3174
--- /dev/null
+++ b/bcc/patch.file
@@ -0,0 +1,157 @@
+diff -u5 -r bcc~/declare.c bcc/declare.c
+--- bcc~/declare.c Fri Dec 17 17:51:13 1999
++++ bcc/declare.c Thu Jun 6 13:27:00 2002
+@@ -410,16 +410,17 @@
+ }
+
+ PRIVATE bool_pt declspec()
+ {
+ unsigned nsc;
++ unsigned nsigned;
+ unsigned ntype;
+ unsigned nunsigned;
+
+ gvarsc = NULLDECL;
+ gvartype = itype;
+- nunsigned = ntype = nsc = 0;
++ nsigned = nunsigned = ntype = nsc = 0;
+ while (TRUE)
+ {
+ switch (sym)
+ {
+ case AUTODECL:
+@@ -482,29 +483,37 @@
+ goto break2;
+ ++ntype;
+ gvartype = gsymptr->type;
+ nextsym();
+ break;
++ case SIGNDECL:
++ ++nsigned;
++ nextsym();
++ break;
+ case UNSIGNDECL:
+ ++nunsigned;
+ nextsym();
+ break;
+ default:
+ goto break2;
+ }
+ }
++
+ break2:
++ if (nsigned > 0)
++ {
++ if (ntype++ == 0)
++ gvartype = itype;
++ else
++ gvartype = tosigned(gvartype);
++ }
+ if (nunsigned > 0)
+ {
+- if (ntype == 0)
+- {
++ if (ntype++ == 0)
+ gvartype = uitype;
+- ntype = 1;
+- }
+- gvartype = tounsigned(gvartype);
+- if (nunsigned > 1)
+- ntype = 2;
++ else
++ gvartype = tounsigned(gvartype);
+ }
+ if (nsc > 0)
+ {
+ if (ntype == 0)
+ ntype = 1;
+diff -u5 -r bcc~/proto.h bcc/proto.h
+--- bcc~/proto.h Sun Jan 11 12:18:36 1998
++++ bcc/proto.h Thu Jun 6 00:46:24 2002
+@@ -360,8 +360,8 @@
+ void outntypechar P((struct typestruct *type));
+ struct typestruct *pointype P((struct typestruct *type));
+ struct typestruct *prefix P((constr_pt constructor, uoffset_T size,
+ struct typestruct *type));
+ struct typestruct *promote P((struct typestruct *type));
++struct typestruct *tosigned P((struct typestruct *type));
+ struct typestruct *tounsigned P((struct typestruct *type));
+ void typeinit P((void));
+-
+diff -u5 -r bcc~/scan.h bcc/scan.h
+--- bcc~/scan.h Sat Jul 24 14:27:42 1999
++++ bcc/scan.h Thu Jun 6 00:32:20 2002
+@@ -134,10 +134,11 @@
+
+ #define LASTOP PTRSUBOP
+
+ ENUMDECL,
+ NULLDECL,
++ SIGNDECL,
+ STRUCTDECL,
+ TYPEDECL,
+ TYPEDEFNAME,
+ UNIONDECL,
+ UNSIGNDECL,
+diff -u5 -r bcc~/table.c bcc/table.c
+--- bcc~/table.c Sun Sep 28 09:57:30 1997
++++ bcc/table.c Thu Jun 6 00:29:36 2002
+@@ -28,11 +28,11 @@
+ #define MAXEXPR 125
+ #else
+ #define MAXEXPR 500
+ #endif
+ #define MAXLOCAL 100
+-#define NKEYWORDS 35
++#define NKEYWORDS 36
+ #ifdef NOFLOAT
+ #define NSCALTYPES 10
+ #else
+ #define NSCALTYPES 12
+ #endif
+@@ -88,11 +88,12 @@
+ PRIVATE struct keywordstruct keywords[NKEYWORDS] =
+ {
+ { "enum", ENUMDECL, },
+ { "struct", STRUCTDECL, },
+ { "union", UNIONDECL, },
+ { "unsigned", UNSIGNDECL, },
++ { "signed", SIGNDECL, },
+
+ { "auto", AUTODECL, },
+ { "extern", EXTERNDECL, },
+ { "register", REGDECL, },
+ { "static", STATICDECL, },
+diff -u5 -r bcc~/type.c bcc/type.c
+--- bcc~/type.c Sun Jan 11 12:18:37 1998
++++ bcc/type.c Thu Jun 6 00:49:06 2002
+@@ -155,10 +155,29 @@
+ if (type->constructor & FUNCTION)
+ return pointype(type);
+ return type;
+ }
+
++PUBLIC struct typestruct *tosigned(type)
++struct typestruct *type;
++{
++ switch (type->scalar & ~(UNSIGNED | DLONG))
++ {
++ case CHAR:
++ return sctype;
++ case SHORT:
++ return stype;
++ case INT:
++ return itype;
++ case LONG:
++ return ltype;
++ default:
++ error("signed only applies to integral types");
++ return type;
++ }
++}
++
+ PUBLIC struct typestruct *tounsigned(type)
+ struct typestruct *type;
+ {
+ switch (type->scalar & ~(UNSIGNED | DLONG))
+ {
diff --git a/bcc/proto.h b/bcc/proto.h
index e4a6b38..d5bbb7d 100644
--- a/bcc/proto.h
+++ b/bcc/proto.h
@@ -362,6 +362,6 @@ struct typestruct *pointype P((struct typestruct *type));
struct typestruct *prefix P((constr_pt constructor, uoffset_T size,
struct typestruct *type));
struct typestruct *promote P((struct typestruct *type));
+struct typestruct *tosigned P((struct typestruct *type));
struct typestruct *tounsigned P((struct typestruct *type));
void typeinit P((void));
-
diff --git a/bcc/q b/bcc/q
new file mode 100644
index 0000000..e124394
--- /dev/null
+++ b/bcc/q
@@ -0,0 +1,112 @@
+diff -u5 -r bcc~/declare.c bcc/declare.c
+--- bcc~/declare.c Fri Dec 17 17:51:13 1999
++++ bcc/declare.c Thu Jun 6 13:27:00 2002
+@@ -410,16 +410,17 @@
+ }
+
+ PRIVATE bool_pt declspec()
+ {
+ unsigned nsc;
++ unsigned nsigned;
+ unsigned ntype;
+ unsigned nunsigned;
+
+ gvarsc = NULLDECL;
+ gvartype = itype;
+- nunsigned = ntype = nsc = 0;
++ nsigned = nunsigned = ntype = nsc = 0;
+ while (TRUE)
+ {
+ switch (sym)
+ {
+ case AUTODECL:
+diff -u5 -r bcc~/proto.h bcc/proto.h
+--- bcc~/proto.h Sun Jan 11 12:18:36 1998
++++ bcc/proto.h Thu Jun 6 00:46:24 2002
+@@ -360,8 +360,8 @@
+ void outntypechar P((struct typestruct *type));
+ struct typestruct *pointype P((struct typestruct *type));
+ struct typestruct *prefix P((constr_pt constructor, uoffset_T size,
+ struct typestruct *type));
+ struct typestruct *promote P((struct typestruct *type));
++struct typestruct *tosigned P((struct typestruct *type));
+ struct typestruct *tounsigned P((struct typestruct *type));
+ void typeinit P((void));
+-
+diff -u5 -r bcc~/scan.h bcc/scan.h
+--- bcc~/scan.h Sat Jul 24 14:27:42 1999
++++ bcc/scan.h Thu Jun 6 00:32:20 2002
+@@ -134,10 +134,11 @@
+
+ #define LASTOP PTRSUBOP
+
+ ENUMDECL,
+ NULLDECL,
++ SIGNDECL,
+ STRUCTDECL,
+ TYPEDECL,
+ TYPEDEFNAME,
+ UNIONDECL,
+ UNSIGNDECL,
+diff -u5 -r bcc~/table.c bcc/table.c
+--- bcc~/table.c Sun Sep 28 09:57:30 1997
++++ bcc/table.c Thu Jun 6 00:29:36 2002
+@@ -28,11 +28,11 @@
+ #define MAXEXPR 125
+ #else
+ #define MAXEXPR 500
+ #endif
+ #define MAXLOCAL 100
+-#define NKEYWORDS 35
++#define NKEYWORDS 36
+ #ifdef NOFLOAT
+ #define NSCALTYPES 10
+ #else
+ #define NSCALTYPES 12
+ #endif
+@@ -88,11 +88,12 @@
+ PRIVATE struct keywordstruct keywords[NKEYWORDS] =
+ {
+ { "enum", ENUMDECL, },
+ { "struct", STRUCTDECL, },
+ { "union", UNIONDECL, },
+ { "unsigned", UNSIGNDECL, },
++ { "signed", SIGNDECL, },
+
+ { "auto", AUTODECL, },
+ { "extern", EXTERNDECL, },
+ { "register", REGDECL, },
+ { "static", STATICDECL, },
+diff -u5 -r bcc~/type.c bcc/type.c
+--- bcc~/type.c Sun Jan 11 12:18:37 1998
++++ bcc/type.c Thu Jun 6 00:49:06 2002
+@@ -155,10 +155,29 @@
+ if (type->constructor & FUNCTION)
+ return pointype(type);
+ return type;
+ }
+
++PUBLIC struct typestruct *tosigned(type)
++struct typestruct *type;
++{
++ switch (type->scalar & ~(UNSIGNED | DLONG))
++ {
++ case CHAR:
++ return sctype;
++ case SHORT:
++ return stype;
++ case INT:
++ return itype;
++ case LONG:
++ return ltype;
++ default:
++ error("signed only applies to integral types");
++ return type;
++ }
++}
++
+ PUBLIC struct typestruct *tounsigned(type)
+ struct typestruct *type;
+ {
+ switch (type->scalar & ~(UNSIGNED | DLONG))
+ {
diff --git a/bcc/scan.h b/bcc/scan.h
index e318e9e..849610b 100644
--- a/bcc/scan.h
+++ b/bcc/scan.h
@@ -136,6 +136,7 @@ enum scan_states
ENUMDECL,
NULLDECL,
+ SIGNDECL,
STRUCTDECL,
TYPEDECL,
TYPEDEFNAME,
diff --git a/bcc/table.c b/bcc/table.c
index 8b9bfb8..68cbc6a 100644
--- a/bcc/table.c
+++ b/bcc/table.c
@@ -30,7 +30,7 @@
#define MAXEXPR 500
#endif
#define MAXLOCAL 100
-#define NKEYWORDS 35
+#define NKEYWORDS 36
#ifdef NOFLOAT
#define NSCALTYPES 10
#else
@@ -91,6 +91,7 @@ PRIVATE struct keywordstruct keywords[NKEYWORDS] =
{ "struct", STRUCTDECL, },
{ "union", UNIONDECL, },
{ "unsigned", UNSIGNDECL, },
+ { "signed", SIGNDECL, },
{ "auto", AUTODECL, },
{ "extern", EXTERNDECL, },
diff --git a/bcc/type.c b/bcc/type.c
index 97d88d7..10db803 100644
--- a/bcc/type.c
+++ b/bcc/type.c
@@ -157,6 +157,25 @@ struct typestruct *type;
return type;
}
+PUBLIC struct typestruct *tosigned(type)
+struct typestruct *type;
+{
+ switch (type->scalar & ~(UNSIGNED | DLONG))
+ {
+ case CHAR:
+ return sctype;
+ case SHORT:
+ return stype;
+ case INT:
+ return itype;
+ case LONG:
+ return ltype;
+ default:
+ error("signed only applies to integral types");
+ return type;
+ }
+}
+
PUBLIC struct typestruct *tounsigned(type)
struct typestruct *type;
{
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index 40e7817..d7ec4fa 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -16,26 +16,25 @@ default: makeboot makeboot.com monitor.out minix_elks.bin lsys.com
all: bootbin bootsys default tgz
-bootsys: bootfile.sys boottar.sys bootminix.sys
+bootsys: bootfile.sys boottar.sys bootminix.sys monitor.sys
CSRC=minix.c
-SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \
- boot_fpy.s killhd.s
+SSRC=sysboot.s tarboot.s skip.s mbr.s msdos.s noboot.s \
+ boot_fpy.s killhd.s bb_linux.s bb_init1.s bb_init2.s
encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v
bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin
MOBJ=monitor.o commands.o i86_funcs.o relocate.o help.o bzimage.o \
- trk_buf.o min_buf.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o
+ buffer.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o
MSRC=monitor.c commands.c i86_funcs.c relocate.c help.c bzimage.c \
- trk_buf.c min_buf.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c
+ buffer.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c
MINC=i86_funcs.h readfs.h monitor.h
BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v msdos16.v \
- tarboot.v minix.v minixhd.v mbr.v
+ tarboot.v minix.v minixhd.v mbr.v killhd.v
-EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s \
- zimage.s minix_elks.c crc.c lsys.c
+EXTRAS=minix.h zimage.s minix_elks.c lsys.c
install:
@@ -60,12 +59,18 @@ boottar.sys: $(MSRC) $(MINC) tarboot.bin
mv monitor.out boottar.sys
@rm -f $(MOBJ)
-bootminix.sys: $(MSRC) $(MINC) tarboot.bin
+bootminix.sys: $(MSRC) $(MINC) minix.bin
@rm -f $(MOBJ)
make 'CFLAGS=$(CFLAGS) -DMINFLOPPY -i' monitor.out
mv monitor.out bootminix.sys
@rm -f $(MOBJ)
+monitor.sys: $(MSRC) $(MINC)
+ @rm -f $(MOBJ)
+ make 'CFLAGS=$(CFLAGS) -DNOMONITOR -i' monitor.out
+ mv monitor.out monitor.sys
+ @rm -f $(MOBJ)
+
monitor: $(MSRC) $(MINC)
@rm -f $(MOBJ)
make 'CFLAGS=-ansi -H0x8000' monitor.out
@@ -96,7 +101,7 @@ lsys.com: lsys.c msdos.v msdos16.v
$(CC) -Md -O -o lsys.com lsys.c
clean realclean:
- rm -f bootfile.sys boottar.sys bootminix.sys
+ rm -f bootfile.sys boottar.sys bootminix.sys monitor.sys
rm -f monitor makeboot bootblocks.tar.gz
rm -f minix.s minixhd.s minix_elks.s msdos16.s
rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp
diff --git a/bootblocks/bb_init1.s b/bootblocks/bb_init1.s
new file mode 100644
index 0000000..b7e6a6d
--- /dev/null
+++ b/bootblocks/bb_init1.s
@@ -0,0 +1,25 @@
+ORGADDR=0x0600
+
+.org ORGADDR
+entry start
+public start
+start:
+ xor ax,ax
+ mov si,#$7C00
+ mov di,#ORGADDR
+
+ mov ss,ax
+ mov sp,di ! Or ax or si
+
+ push ax
+ pop ds
+ push ax
+ pop es
+
+ mov cx,#256
+ cld
+ rep
+ movsw
+ jmpi go,#0
+go:
+
diff --git a/bootblocks/bb_init2.s b/bootblocks/bb_init2.s
new file mode 100644
index 0000000..b27b8aa
--- /dev/null
+++ b/bootblocks/bb_init2.s
@@ -0,0 +1,17 @@
+ORGADDR=$0500
+
+org ORGADDR
+ cld
+ mov bx,#$7C00 ! Pointer to start of BB.
+ xor ax,ax ! Segs all to zero
+ mov ds,ax
+ mov es,ax
+ mov ss,ax
+ mov sp,bx ! SP Just below BB
+ mov cx,#$100 ! Move 256 words
+ mov si,bx ! From default BB
+ mov di,#ORGADDR ! To the correct address.
+ rep
+ movsw
+ jmpi cont,#0 ! Set CS:IP correct.
+cont:
diff --git a/bootblocks/bb_linux.s b/bootblocks/bb_linux.s
new file mode 100644
index 0000000..6bad72b
--- /dev/null
+++ b/bootblocks/bb_linux.s
@@ -0,0 +1,22 @@
+
+INITSEG = $9000
+
+org 0
+mov ax,#$07c0
+mov ds,ax
+mov ax,#INITSEG
+mov es,ax
+mov cx,#256
+sub si,si
+sub di,di
+cld
+rep
+ movsw
+jmpi go,INITSEG
+go:
+
+mov di,#0x4000-12
+mov ds,ax
+mov ss,ax ! put stack at INITSEG:0x4000-12.
+mov sp,di
+
diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s
index a40d0fa..ced54c7 100644
--- a/bootblocks/boot_fpy.s
+++ b/bootblocks/boot_fpy.s
@@ -169,6 +169,12 @@ load_track:
jnz inc_trk
all_loaded:
+ ! Now it's loaded turn off the floppy motor.
+ mov dx,#0x3f2
+ xor al, al
+ outb
+
+ ! And start up the program.
xor dx,dx ! DX=0 => floppy drive
push dx ! CX=0 => partition offset = 0
diff --git a/bootblocks/buffer.c b/bootblocks/buffer.c
new file mode 100644
index 0000000..d0a90bd
--- /dev/null
+++ b/bootblocks/buffer.c
@@ -0,0 +1,142 @@
+
+#include "monitor.h"
+
+#ifndef MAXTRK
+#define MAXTRK 18
+#endif
+
+int disk_drive = 0;
+int disk_spt = 7;
+int disk_heads = 0;
+int disk_cyls = 0;
+long disk_partition_offset = 0;
+
+static long bad_start = -1;
+static long buf_start = -1;
+static int buf_sec = 0;
+static int buf_len = 0;
+static char buffer[MAXTRK*512]; /* WARNING: This must be DMAable */
+
+void reset_disk()
+{
+ disk_spt = 7; /* Defaults for reading floppy boot area. */
+ disk_heads = 0;
+ disk_cyls = 0;
+ bad_start = -1;
+ disk_partition_offset = 0;
+
+#ifdef __STANDALONE__
+ if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 )
+ {
+ disk_spt = __argr.x.si;
+ disk_heads = 2;
+ disk_cyls = 80;
+ }
+ if( disk_drive & 0x80 )
+ {
+ /* Hard disk, get parameters from bios */
+ long dpt;
+ int v;
+
+ if( disk_drive == __argr.h.dl )
+ disk_partition_offset = __argr.x.cx + ((long)__argr.h.dh<<16);
+
+ dpt = _bios_get_dpt(disk_drive);
+ v = ((dpt>>16) & 0xFF);
+ if( v != 0xFF && v > (disk_drive&0x7F) )
+ {
+ disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */
+ if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */
+ disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */
+ disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1;
+
+ /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be
+ * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl.
+ */
+ }
+ }
+#endif
+}
+
+char * read_lsector(sectno)
+long sectno;
+{
+ int tries;
+ int rv = 0;
+
+ int phy_s = 1;
+ int phy_h = 0;
+ int phy_c = 0;
+
+ long bstart;
+
+ if( sectno == 0 || disk_heads == 0 ) reset_disk();
+ if( disk_partition_offset > 0 ) sectno += disk_partition_offset;
+
+ if( disk_spt < 1 || disk_heads < 1 )
+ phy_s = sectno;
+ else
+ {
+ phy_s = sectno%disk_spt;
+ phy_h = sectno/disk_spt%disk_heads;
+ phy_c = sectno/disk_spt/disk_heads;
+
+ bstart = (long)phy_c*disk_heads+phy_h;
+ if (disk_spt > MAXTRK) {
+ bstart = bstart * (disk_spt+MAXTRK-1)/MAXTRK;
+ buf_sec = phy_s/MAXTRK;
+ bstart = bstart + buf_sec;
+ buf_sec *= MAXTRK;
+
+ if (disk_spt > buf_sec+MAXTRK) buf_len = MAXTRK;
+ else buf_len = disk_spt-buf_sec;
+ } else {
+ buf_sec = 0;
+ buf_len = disk_spt;
+ }
+
+ if( bstart != buf_start && bstart != bad_start && buf_len > 1 )
+ {
+ rv = _bios_disk_read(disk_drive,phy_c,phy_h,buf_sec+1,buf_len,buffer);
+ if( rv == 0 )
+ buf_start = bstart;
+ else {
+ bad_start = bstart;
+ buf_start = -1;
+ }
+#ifdef DEBUG
+ printf("Track read %d,%d,%d,%d,%d,%d -> %d\n",
+ disk_drive,phy_c,phy_h,buf_sec+1,buf_len,buffer, rv);
+#endif
+ }
+
+ if( bstart == buf_start )
+ return buffer + (phy_s-buf_sec) * 512;
+ }
+
+ tries = 6;
+ do
+ {
+ if( rv && tries<0) {
+ int v;
+ printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
+ rv, disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
+ printf("Retry ?"); v = (getch()&0x7F); printf("\n");
+ if (v == 3 || v == 27 || v == 'n' || v == 'N')
+ return 0;
+ tries = 6;
+ }
+
+ if (tries == 3) _bios_disk_reset(disk_drive);
+
+ rv = _bios_disk_read(disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
+ tries--;
+ }
+ while(rv);
+#ifdef DEBUG
+ printf("Sector read %d,%d,%d,%d,%d,%d -> %d\n",
+ disk_drive,phy_c,phy_h,phy_s+1,1,buffer, rv);
+#endif
+
+ if(rv) return 0; else return buffer;
+}
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index 8540cd6..d9d92bc 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -106,10 +106,6 @@ char * command_line;
}
if( main_mem_top < 3072 )
printf("RTFM warning: Linux needs at least 4MB of memory.\n");
-
- len = (len+1023)/1024+1; /* Where to load the RD image (Mb) */
- if (len<6) len=6; /* Default to 6Mb mark */
- initrd_start = len * 4096; /* 256 bytes pages. */
#endif
low_sects = buffer[497] + 1; /* setup sects + boot sector */
@@ -214,6 +210,7 @@ char * command_line;
if( check_crc() < 0 && !keep_going() ) return -1;
#endif
+#ifndef NOMONITOR
if( x86 < 3 || x86_emu )
{
if( x86 < 3 )
@@ -222,6 +219,7 @@ char * command_line;
printf("RTFM error: Linux-i386 cannot be run in an emulator.\n");
if( !keep_going() ) return -1;
}
+#endif
printf("linux ");
if( linux_command_line )
@@ -229,19 +227,6 @@ char * command_line;
printf("\n");
fflush(stdout);
- if( a20_closed() ) open_a20();
- if( a20_closed() )
- {
- printf("Normal routine for opening A20 Gate failed, Trying PS/2 Bios\n");
- bios_open_a20();
- }
- if( a20_closed() )
- {
- printf("All routines for opening A20 Gate failed, if I can't open it\n");
- printf("then Linux probably can't either!\n");
- if( !keep_going() ) return -1;
- }
-
__set_es(0x9000);
/* Save pointer to command line */
@@ -690,8 +675,6 @@ unsigned int k_top;
rd_start = address - rd_len*4;
rd_start &= -16; /* Page boundry */
- if (initrd_start && initrd_start<rd_start)
- rd_start = initrd_start;
address = rd_start;
printf("Loading %s at 0x%x00\n", fname, rd_start);
diff --git a/bootblocks/com_bcc.s b/bootblocks/com_bcc.s
deleted file mode 100644
index 061575f..0000000
--- a/bootblocks/com_bcc.s
+++ /dev/null
@@ -1,65 +0,0 @@
-
-! This header assumes only that we're loaded at a 16 byte boundry
-
-ENDOFF=4 ! If you add code adjust this till it stops failing.
-
-org 0
-entry start
-public start
-start:
- call chk ! This chunk allows this code to exist at _any_ click
-chk:
- pop ax
- mov cl,#4
- shr ax,cl
- mov bx,cs
- add ax,bx
- push ax
- mov bx,#going
- push bx
- retf
-going:
- mov ds,ax
-
- add ax,#ENDOFF+2 ! New CS
- mov bx,ax ! Saved
- mov dx,[a_entry] ! Save the entry - zero
- mov ax,[btype]
- and ax,#$20 ! Split I/D ?
- jz impure
- mov cl,#4
- mov ax,[a_text]
- shr ax,cl
-impure: ! ax is now offset 'tween CS&DS
- add ax,bx ! ax = DS
- mov ss,ax
- mov sp,[a_total] ! SS:SP is now ready for prog.
- mov ds,ax
- xor cx,cx ! argc, argv and envp = 0
- push cx
- push cx
- push cx
- push bx ! CS
- push dx ! Entry address
- retf ! Gone.
-
-! Check for overlap
-end_of_code:
- if end_of_code>hitme
- fail! At end_of_code
- endif
-
-.org ((ENDOFF)<<4)-1
-hitme:
-.byte 0xFF ! Marker
-
-magic: .space 2 ! A.out header
-btype: .space 2
-headerlen: .space 4
-a_text: .space 4
-a_data: .space 4
-a_bss: .space 4
-a_entry: .space 4
-a_total: .space 4
-a_syms: .space 4
-.org (ENDOFF+2)<<4 ! Code start.
diff --git a/bootblocks/crc.c b/bootblocks/crc.c
deleted file mode 100644
index 88c43a5..0000000
--- a/bootblocks/crc.c
+++ /dev/null
@@ -1,216 +0,0 @@
-
-#include <stdio.h>
-
-/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
-static unsigned short crctab[256] = {
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
- 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
- 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
- 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
- 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
- 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
- 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
- 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
- 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
- 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
- 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
- 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
- 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
- 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
- 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
- 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
- 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
- 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
- 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
- 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
- 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
- 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
- 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-/*
- * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
- * NOTE: First srgument must be in range 0 to 255.
- * Second argument is referenced twice.
- *
- * Programmers may incorporate any or all code into their programs,
- * giving proper credit within the source. Publication of the
- * source routines is permitted so long as proper credit is given
- * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
- * Omen Technology.
- */
-
-#define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp)
-
-/*
- * Copyright (C) 1986 Gary S. Brown. You may use this program, or
- * code or tables extracted from it, as desired without restriction.
- */
-
-/* First, the polynomial itself and its table of feedback terms. The */
-/* polynomial is */
-/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
-/* Note that we take it "backwards" and put the highest-order term in */
-/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
-/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
-/* the MSB being 1. */
-
-/* Note that the usual hardware shift register implementation, which */
-/* is what we're using (we're merely optimizing it by doing eight-bit */
-/* chunks at a time) shifts bits into the lowest-order term. In our */
-/* implementation, that means shifting towards the right. Why do we */
-/* do it this way? Because the calculated CRC must be transmitted in */
-/* order from highest-order term to lowest-order term. UARTs transmit */
-/* characters in order from LSB to MSB. By storing the CRC this way, */
-/* we hand it to the UART in the order low-byte to high-byte; the UART */
-/* sends each low-bit to hight-bit; and the result is transmission bit */
-/* by bit from highest- to lowest-order term without requiring any bit */
-/* shuffling on our part. Reception works similarly. */
-
-/* The feedback terms table consists of 256, 32-bit entries. Notes: */
-/* */
-/* The table can be generated at runtime if desired; code to do so */
-/* is shown later. It might not be obvious, but the feedback */
-/* terms simply represent the results of eight shift/xor opera- */
-/* tions for all combinations of data and CRC register values. */
-/* */
-/* The values must be right-shifted by eight bits by the "updcrc" */
-/* logic; the shift must be unsigned (bring in zeroes). On some */
-/* hardware you could probably optimize the shift in assembler by */
-/* using byte-swap instructions. */
-
-static long cr3tab[] = { /* CRC polynomial 0xedb88320 */
-0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
-0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
-0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
-0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
-0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
-0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
-0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
-0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
-0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
-0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
-0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
-0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
-0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
-0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
-0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
-0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
-0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
-0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF))
-
-int skip = 0;
-int do_16 = 0;
-int do_hex = 0;
-
-main(argc, argv)
-int argc;
-char ** argv;
-{
- int ar;
- int done = 0;
- for(ar=1; ar<argc; ar++) if( argv[ar][0] == '-' )
- {
- switch(argv[ar][1])
- {
- case 's': do_16 = 1; break;
- case 't': do_16 = 0; break;
- case 'h': do_hex = 1; break;
- default:
- fprintf(stderr, "Usage: %s -sth +skip files\n", argv[0]);
- exit(1);
- }
- }
- else if( argv[ar][0] == '+' )
- {
- skip = atoi(argv[ar]+1);
- }
- else
- {
- do_crc(argv[ar]);
- done++;
- }
- if( done == 0 )
- {
- fprintf(stderr, "Usage: %s -sth +skip files\n", argv[0]);
- exit(1);
- }
- exit(0);
-}
-
-do_crc(fname)
-char * fname;
-{
- FILE * fd;
- unsigned short crc = 0;
- long crc32 = -1;
- int ch;
- long count = 0;
-
- fd = fopen(fname, "r");
- if( fd == 0 )
- {
- printf("%s:\tCannot open\n", fname);
- exit(1);
- }
-
- while((ch=getc(fd)) != EOF)
- {
- if( count >= skip )
- {
- crc = updcrc(ch, crc);
- crc32 = UPDC32(ch, crc32);
- }
- count++;
- }
- fclose(fd);
- crc32 ^= 0xFFFFFFFF;
-
- printf("%-14s: %6ld CRC32=0x%08lx (%10lu)", fname, count, crc32, crc32);
- printf(" CRC16=0x%04lx (%5u)\n", crc, crc);
-
-/*
- if(do_hex)
- {
- if(do_16)
- printf("%-14s:\t%6ld %04x\n", fname, count, crc);
- else
- printf("%-14s:\t%6ld %08lx\n", fname, count, crc32);
- }
- else
- {
- if(do_16)
- printf("%-14s:\t%6ld %5u\n", fname, count, crc);
- else
- printf("%-14s:\t%6ld %10lu\n", fname, count, crc32);
- }
-*/
- fflush(stdout);
-}
-
diff --git a/bootblocks/elf_info.c b/bootblocks/elf_info.c
deleted file mode 100644
index 86fa392..0000000
--- a/bootblocks/elf_info.c
+++ /dev/null
@@ -1,189 +0,0 @@
-
-#include <stdio.h>
-#include "elf_info.h"
-
-Elf32_Ehdr elf_head;
-Elf32_Phdr *elf_prog;
-
-#ifdef TEST
-FILE *ifd;
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- ifd = fopen(argv[1], "r");
- if (ifd == 0)
- exit(1);
-
- read_elfprog();
- write_ram("", -1L, 0);
-
- fclose(ifd);
-}
-
-read_file(buf, offset, len)
-void *buf;
-long offset;
-int len;
-{
- fseek(ifd, offset, 0);
- return fread(buf, 1, len, ifd);
-}
-
-write_ram(buf, linear, len)
-char *buf;
-long linear;
-int len;
-{
-static long llen = 0;
-static long lastlin= -1;
-
- if( llen > 0 && lastlin + llen != linear )
- {
- printf("for %8ld bytes\n", llen);
- lastlin= -1;
- }
- if( lastlin == -1 )
- {
- lastlin = linear;
- llen = 0;
-
- if( linear != -1 )
- printf("Write %08lx ", linear);
- }
- llen += len;
- return len;
-}
-
-error(str)
-char *str;
-{
- printf("Error: %s\n", str);
- return -1;
-}
-#endif
-
-info_elf()
-{
- int i;
-
- printf("ELF-386 executable, entry = 0x%08lx\n", elf_head.e_entry);
- printf("\t\toffset paddr vaddr filesz memsz align\n");
- for (i = 0; i < elf_head.e_phnum; i++)
- {
- printf(" %d: ", i);
- switch ((int) elf_prog[i].p_type)
- {
- case PT_NULL:
- printf("PT_NULL");
- break;
- case PT_LOAD:
- printf("PT_LOAD");
- break;
- case PT_DYNAMIC:
- printf("PT_DYNAMIC");
- break;
- case PT_INTERP:
- printf("PT_INTERP");
- break;
- case PT_NOTE:
- printf("PT_NOTE");
- break;
- case PT_SHLIB:
- printf("PT_SHLIB");
- break;
- case PT_PHDR:
- printf("PT_PHDR");
- break;
- default:
- printf("PT_(%d)", elf_prog[i].p_type);
- break;
- }
- printf("\t%08lx %08lx %08lx %08lx %08lx %08lx",
- elf_prog[i].p_offset,
- elf_prog[i].p_paddr,
- elf_prog[i].p_vaddr,
- elf_prog[i].p_filesz,
- elf_prog[i].p_memsz,
- elf_prog[i].p_align
- );
- printf("\n");
- }
-}
-
-read_elfprog()
-{
- static unsigned char elf_ok[] =
- {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS32, ELFDATA2LSB, EV_CURRENT};
-
- int i;
- char page_buf[4096];
-
- if (read_file(&elf_head, 0L, sizeof(elf_head)) != sizeof(elf_head))
- return error("Can't read ELF header");
-
- if (memcmp(elf_head.e_ident, elf_ok, 7) != 0 ||
- elf_head.e_type != ET_EXEC ||
- elf_head.e_machine != EM_386 ||
- elf_head.e_phnum <= 0 ||
- elf_head.e_phentsize != sizeof(Elf32_Phdr)
- )
- return error("Not a 386 executable ELF program");
-
- elf_prog = malloc(i = sizeof(Elf32_Phdr) * elf_head.e_phnum);
- if (elf_prog == 0)
- return error("Out of memory");
-
- if (read_file(elf_prog, elf_head.e_phoff, i) != i)
- return error("Can't read ELF program header");
-
- info_elf();
-
- for (i = 0; i < elf_head.e_phnum; i++)
- {
- long from, to, length, copied;
- int chunk;
-
- switch ((int) elf_prog[i].p_type)
- {
- case PT_NULL:
- case PT_NOTE:
- continue;
- default:
- return error("ELF: Unusable program segment (Must be static)");
- case PT_LOAD:
- break;
- }
- from=elf_prog[i].p_offset;
- to=elf_prog[i].p_vaddr;
- length=elf_prog[i].p_filesz;
-
- for(copied=0; copied<length; )
- {
- if(length>copied+sizeof(page_buf)) chunk=sizeof(page_buf);
- else chunk=length-copied;
-
- if( (chunk=read_file(page_buf, from, chunk)) <= 0 )
- return error("ELF Cannot read executable");
- if( write_ram(page_buf, to, chunk) < 0 )
- return error("Memory save failed");
- copied+=chunk; from+=chunk; to+=chunk;
- }
- length=elf_prog[i].p_memsz;
- if( length > copied )
- {
- write_ram("", -1L, 0);
- memset(page_buf, '\0', sizeof(page_buf));
- for(; copied<length; )
- {
- if(length>copied+sizeof(page_buf)) chunk=sizeof(page_buf);
- else chunk=length-copied;
-
- if( write_ram(page_buf, to, chunk) < 0 )
- return error("Memory zap failed");
- copied+=chunk; to+=chunk;
- }
- }
- }
-}
diff --git a/bootblocks/elf_info.h b/bootblocks/elf_info.h
deleted file mode 100644
index a011d97..0000000
--- a/bootblocks/elf_info.h
+++ /dev/null
@@ -1,282 +0,0 @@
-
-/* ELF layout information */
-
-/* NOTE: I'm copying the file format information here because the _format_
- * is standard, but the Linux header files are not and may depend on
- * headers not available when compiling Linux-86 code.
- */
-
-#ifndef _LINUX_ELF_H
-#define _LINUX_ELF_H
-
-typedef unsigned long Elf32_Addr;
-typedef unsigned short Elf32_Half;
-typedef unsigned long Elf32_Off;
-typedef long Elf32_Sword;
-typedef unsigned long Elf32_Word;
-
-/* These constants are for the segment types stored in the image headers */
-#define PT_NULL 0
-#define PT_LOAD 1
-#define PT_DYNAMIC 2
-#define PT_INTERP 3
-#define PT_NOTE 4
-#define PT_SHLIB 5
-#define PT_PHDR 6
-#define PT_LOPROC 0x70000000L
-#define PT_HIPROC 0x7fffffffL
-
-/* These constants define the different elf file types */
-#define ET_NONE 0
-#define ET_REL 1
-#define ET_EXEC 2
-#define ET_DYN 3
-#define ET_CORE 4
-#define ET_LOPROC 5
-#define ET_HIPROC 6
-
-/* These constants define the various ELF target machines */
-#define EM_NONE 0
-#define EM_M32 1
-#define EM_SPARC 2
-#define EM_386 3
-#define EM_68K 4
-#define EM_88K 5
-#define EM_486 6 /* Perhaps disused */
-#define EM_860 7
-
-/* This is the info that is needed to parse the dynamic section of the file */
-#define DT_NULL 0
-#define DT_NEEDED 1
-#define DT_PLTRELSZ 2
-#define DT_PLTGOT 3
-#define DT_HASH 4
-#define DT_STRTAB 5
-#define DT_SYMTAB 6
-#define DT_RELA 7
-#define DT_RELASZ 8
-#define DT_RELAENT 9
-#define DT_STRSZ 10
-#define DT_SYMENT 11
-#define DT_INIT 12
-#define DT_FINI 13
-#define DT_SONAME 14
-#define DT_RPATH 15
-#define DT_SYMBOLIC 16
-#define DT_REL 17
-#define DT_RELSZ 18
-#define DT_RELENT 19
-#define DT_PLTREL 20
-#define DT_DEBUG 21
-#define DT_TEXTREL 22
-#define DT_JMPREL 23
-#define DT_LOPROC 0x70000000L
-#define DT_HIPROC 0x7fffffffL
-
-/* This info is needed when parsing the symbol table */
-#define STB_LOCAL 0
-#define STB_GLOBAL 1
-#define STB_WEAK 2
-
-#define STT_NOTYPE 0
-#define STT_OBJECT 1
-#define STT_FUNC 2
-#define STT_SECTION 3
-#define STT_FILE 4
-
-#define ELF32_ST_BIND(x) ((x) >> 4)
-#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
-
-/* Symbolic values for the entries in the auxiliary table
- put on the initial stack */
-#define AT_NULL 0 /* end of vector */
-#define AT_IGNORE 1 /* entry should be ignored */
-#define AT_EXECFD 2 /* file descriptor of program */
-#define AT_PHDR 3 /* program headers for program */
-#define AT_PHENT 4 /* size of program header entry */
-#define AT_PHNUM 5 /* number of program headers */
-#define AT_PAGESZ 6 /* system page size */
-#define AT_BASE 7 /* base address of interpreter */
-#define AT_FLAGS 8 /* flags */
-#define AT_ENTRY 9 /* entry point of program */
-#define AT_NOTELF 10 /* program is not ELF */
-#define AT_UID 11 /* real uid */
-#define AT_EUID 12 /* effective uid */
-#define AT_GID 13 /* real gid */
-#define AT_EGID 14 /* effective gid */
-
-
-typedef struct dynamic{
- Elf32_Sword d_tag;
- union{
- Elf32_Sword d_val;
- Elf32_Addr d_ptr;
- } d_un;
-} Elf32_Dyn;
-
-extern Elf32_Dyn _DYNAMIC [];
-
-/* The following are used with relocations */
-#define ELF32_R_SYM(x) ((x) >> 8)
-#define ELF32_R_TYPE(x) ((x) & 0xff)
-
-#define R_386_NONE 0
-#define R_386_32 1
-#define R_386_PC32 2
-#define R_386_GOT32 3
-#define R_386_PLT32 4
-#define R_386_COPY 5
-#define R_386_GLOB_DAT 6
-#define R_386_JMP_SLOT 7
-#define R_386_RELATIVE 8
-#define R_386_GOTOFF 9
-#define R_386_GOTPC 10
-#define R_386_NUM 11
-
-typedef struct elf32_rel {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-} Elf32_Rel;
-
-typedef struct elf32_rela{
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-} Elf32_Rela;
-
-typedef struct elf32_sym{
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-} Elf32_Sym;
-
-
-#define EI_NIDENT 16
-
-typedef struct elfhdr{
- unsigned char e_ident[EI_NIDENT];
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry; /* Entry point */
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
- Elf32_Half e_shstrndx;
-} Elf32_Ehdr;
-
-/* These constants define the permissions on sections in the program
- header, p_flags. */
-#define PF_R 0x4
-#define PF_W 0x2
-#define PF_X 0x1
-
-typedef struct elf_phdr{
- Elf32_Word p_type;
- Elf32_Off p_offset;
- Elf32_Addr p_vaddr;
- Elf32_Addr p_paddr;
- Elf32_Word p_filesz;
- Elf32_Word p_memsz;
- Elf32_Word p_flags;
- Elf32_Word p_align;
-} Elf32_Phdr;
-
-/* sh_type */
-#define SHT_NULL 0
-#define SHT_PROGBITS 1
-#define SHT_SYMTAB 2
-#define SHT_STRTAB 3
-#define SHT_RELA 4
-#define SHT_HASH 5
-#define SHT_DYNAMIC 6
-#define SHT_NOTE 7
-#define SHT_NOBITS 8
-#define SHT_REL 9
-#define SHT_SHLIB 10
-#define SHT_DYNSYM 11
-#define SHT_NUM 12
-#define SHT_LOPROC 0x70000000L
-#define SHT_HIPROC 0x7fffffffL
-#define SHT_LOUSER 0x80000000L
-#define SHT_HIUSER 0xffffffffL
-
-/* sh_flags */
-#define SHF_WRITE 0x1
-#define SHF_ALLOC 0x2
-#define SHF_EXECINSTR 0x4
-#define SHF_MASKPROC 0xf0000000L
-
-/* special section indexes */
-#define SHN_UNDEF 0
-#define SHN_LORESERVE 0xff00L
-#define SHN_LOPROC 0xff00L
-#define SHN_HIPROC 0xff1fL
-#define SHN_ABS 0xfff1L
-#define SHN_COMMON 0xfff2L
-#define SHN_HIRESERVE 0xffffL
-
-typedef struct {
- Elf32_Word sh_name;
- Elf32_Word sh_type;
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
-} Elf32_Shdr;
-
-#define EI_MAG0 0 /* e_ident[] indexes */
-#define EI_MAG1 1
-#define EI_MAG2 2
-#define EI_MAG3 3
-#define EI_CLASS 4
-#define EI_DATA 5
-#define EI_VERSION 6
-#define EI_PAD 7
-
-#define ELFMAG0 0x7f /* EI_MAG */
-#define ELFMAG1 'E'
-#define ELFMAG2 'L'
-#define ELFMAG3 'F'
-#define ELFMAG "\177ELF"
-#define SELFMAG 4
-
-#define ELFCLASSNONE 0 /* EI_CLASS */
-#define ELFCLASS32 1
-#define ELFCLASS64 2
-#define ELFCLASSNUM 3
-
-#define ELFDATANONE 0 /* e_ident[EI_DATA] */
-#define ELFDATA2LSB 1
-#define ELFDATA2MSB 2
-
-#define EV_NONE 0 /* e_version, EI_VERSION */
-#define EV_CURRENT 1
-#define EV_NUM 2
-
-/* Notes used in ET_CORE */
-#define NT_PRSTATUS 1
-#define NT_PRFPREG 2
-#define NT_PRPSINFO 3
-#define NT_TASKSTRUCT 4
-
-/* Note header in a PT_NOTE section */
-typedef struct elf_note {
- Elf32_Word n_namesz; /* Name size */
- Elf32_Word n_descsz; /* Content size */
- Elf32_Word n_type; /* Content type */
-} Elf32_Nhdr;
-
-#endif /* _LINUX_ELF_H */
diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c
index 2112141..7d010f5 100644
--- a/bootblocks/i86_funcs.c
+++ b/bootblocks/i86_funcs.c
@@ -1,77 +1,21 @@
#include "monitor.h"
-int x86 = 0; /* CPU major number */
+#ifndef NOMONITOR
+int x86 = 3; /* CPU major number */
char *x86_name = ""; /* and it's name */
int x86_emu = 0; /* Is this a PC emulator ? */
-int x86_a20_closed = 1; /* Is the A20 gate closed ? */
int x86_fpu = 0;
+#endif
int x86_test = 0; /* In test mode */
unsigned boot_mem_top = 0x2000; /* Default 128k, the minimum */
long main_mem_top = 0; /* K of extended memory */
-int a20_closed()
-{
- register int v, rv = 0;
- if (x86_test) return 1; /* If not standalone don't try */
-
- __set_es(0);
- v = __peek_es(512);
- __set_es(0xFFFF);
- if (v == __peek_es(512+16))
- {
- __set_es(0);
- __poke_es(512, v+1);
- __set_es(0xFFFF);
- if (v+1 == __peek_es(512+16))
- rv = 1;
- __set_es(0);
- __poke_es(512, v);
- }
- return x86_a20_closed = rv;
-}
-
-static void asm_open_a20()
-{
-#asm
- call empty_8042
- mov al,#0xD1 ! command write
- out #0x64,al
- call empty_8042
- mov al,#0xDF ! A20 on
- out #0x60,al
-empty_8042:
- .word 0x00eb,0x00eb
- in al,#0x64 ! 8042 status port
- test al,#2 ! is input buffer full?
- jnz empty_8042 ! yes - loop, with no timeout!
-#endasm
-}
-
-void open_a20() { if(!x86_test) asm_open_a20(); }
-
-/* This calls the BIOS to open the A20 gate, officially this is only supported
- on PS/2s but if the normal routine fails we may as well try this.
- */
-void asm_bios_open_a20()
-{
-#asm
- mov ax,#$2401
- int $15
- jc bios_failed_a20
- xor ax,ax
-bios_failed_a20:
- mov al,ah
- xor ah,ah
-#endasm
-}
-
-void bios_open_a20() { if(!x86_test) asm_bios_open_a20(); }
-
void cpu_check()
{
+#ifndef NOMONITOR
static char *name_808x[] =
{
"8088", "8086", "80C88", "80C86", "NEC V20", "NEC V30", "808x Clone"
@@ -107,8 +51,12 @@ void cpu_check()
if (c & 0x01) x86_emu = 1; /* Already in protected mode !!! */
}
-#ifdef __STANDALONE__
x86_test = x86_emu;
+ if (x86<3)
+ x86_test = 1;
+#endif
+
+#ifdef __STANDALONE__
if (__argr.x.cflag)
x86_test = 1;
#else
@@ -118,35 +66,27 @@ void cpu_check()
void mem_check()
{
-#ifndef __STANDALONE__
- main_mem_top = 16384;
- return; /* If not standalone don't try */
-#else
+ if (x86_test) {
+ main_mem_top = 0;
+ return;
+ }
+
#asm
int 0x12 ! Amount of boot memory
mov cl,#6
sal ax,cl ! In segments
mov [_boot_mem_top],ax
- ! Next check for extended
- mov al,[_x86] ! If we ain't got a 286+ we can't access it anyway
- cmp al,#2
- jl is_xt
-
- mov ah,#0x88 !
+ mov ah,#0x88 ! Next check for extended
int 0x15
- jnc got_ext ! Error!? This should _not_ happen ... but ...
+ jnc got_ext ! Error!
is_xt:
xor ax,ax
got_ext:
mov word ptr [_main_mem_top+2],#0
mov [_main_mem_top],ax
-
#endasm
- /* Rest are big memory for 80386+ */
- if( x86 < 3 ) return;
-
/* Try int $15 EAX=$E820 */
{
struct e820_dat {
@@ -202,8 +142,6 @@ got_e820:
no_e801:
#endasm
}
-
-#endif
}
#define RIGHTS (0x93000000L)
diff --git a/bootblocks/i86_funcs.h b/bootblocks/i86_funcs.h
index 2fdb860..798b827 100644
--- a/bootblocks/i86_funcs.h
+++ b/bootblocks/i86_funcs.h
@@ -5,16 +5,12 @@
extern int x86; /* CPU major number (0-3) */
extern char *x86_name; /* and it's name */
extern int x86_emu; /* Is this a PC emulator ? */
-extern int x86_a20_closed; /* Is the A20 gate closed ? */
extern int x86_fpu;
extern int x86_test; /* Running in test mode ? */
extern unsigned boot_mem_top; /* Top of RAM below 1M */
extern long main_mem_top; /* Top of RAM above 1M */
-int a20_closed();
-void open_a20();
-void bios_open_a20();
void cpu_check();
void mem_check();
int ext_put();
diff --git a/bootblocks/li86.s b/bootblocks/li86.s
deleted file mode 100644
index cabbc15..0000000
--- a/bootblocks/li86.s
+++ /dev/null
@@ -1,47 +0,0 @@
-!----------------------------------------------------------------------------
-!
-! This is a skeleton for creating an impure Linux-8086 executable without
-! using the linker. The .text and .data areas are correctly positioned.
-!
-! This file needs to be compiled using the 3 pass mode (-O)
-! eg: as86 -O li86.s -s li86.sym -b li86.bin
-!
-!----------------------------------------------------------------------------
-.text
-org -32
-.word 0x0301 ! Magic
-.word 0x0410 ! Btype
-.long 0x20 ! header length
-.long _etext ! a_text
-.long _edata-_etext ! a_data
-.long 0 ! a_bss
-.long 0 ! a_entry
-.long STACK_SIZE ! a_total
-.long 0 ! a_syms
-.data
-.blkb _etext
-.even
-.text
-!----------------------------------------------------------------------------
-
-STACK_SIZE = 0x10000
-
-.data
-var:
-.word $1234
-
-.text
- int $20
- mov ax,var
- mov bx,_edata
- push ax
- ret
-
-!----------------------------------------------------------------------------
-! This trailer must be at the end of the file.
-.text
-_etext:
-.data
-_edata:
-END
-
diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c
index 77403c3..a7a02ac 100644
--- a/bootblocks/makeboot.c
+++ b/bootblocks/makeboot.c
@@ -9,6 +9,7 @@
#include "msdos.v"
#include "msdos16.v"
#include "skip.v"
+#include "killhd.v"
#include "tarboot.v"
#include "minix.v"
#include "minixhd.v"
@@ -58,6 +59,9 @@ struct bblist {
{ "hdmin","Minix Hard disk FS booter",
minixhd_data, minixhd_size,
2, minixhd_bootfile-minixhd_start, FS_ZERO},
+{ "killhd", "Deletes MBR from hard disk when booted",
+ killhd_data, killhd_size,
+ 0, 0, FS_ADOS},
#ifdef mbr_Banner
{ "mbr", "Master boot record for HD (with optional message)",
mbr_data,mbr_size,
diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s
index a5e4585..a5a3923 100644
--- a/bootblocks/mbr.s
+++ b/bootblocks/mbr.s
@@ -394,7 +394,8 @@ diskman_magic:
org ORGADDR+0x180
.asciz "ELKS MBR "
.asciz "Robert de Bath,"
-.asciz "Copyright 1996-2000."
+.asciz "Copyright "
+.asciz "1996-2002. "
org partition_start-1
.byte 0xFF
endif
diff --git a/bootblocks/min_buf.c b/bootblocks/min_buf.c
deleted file mode 100644
index 75d2043..0000000
--- a/bootblocks/min_buf.c
+++ /dev/null
@@ -1,119 +0,0 @@
-
-#include "monitor.h"
-
-#ifdef MINI_BUF
-#ifndef MAXTRK
-#define MAXTRK 21
-#endif
-
-int disk_drive = 0;
-int disk_spt = 7;
-int disk_heads = 0;
-int disk_cyls = 0;
-int bad_track = -1;
-
-static int track_no = -1;
-static int buf_len = 0;
-static char buffer[MAXTRK*512]; /* WARNING: This must be DMAable */
-
-void reset_disk()
-{
- disk_spt = 7;
- disk_heads = 0;
- disk_cyls = 0;
- bad_track = -1;
-
-#ifdef __STANDALONE__
- if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 )
- {
- disk_spt = __argr.x.si;
- disk_heads = 2;
- disk_cyls = 80;
- }
-#endif
-}
-
-char * read_lsector(sectno)
-long sectno;
-{
- int tries = 5;
- int rv = 0;
-
- int phy_s = 1;
- int phy_h = 0;
- int phy_c = 0;
- int ltrack;
-
- if( sectno == 0 || disk_heads == 0 ) reset_disk();
- if( buf_len != disk_spt ) track_no = -1;
-
- if( disk_spt < 1 || disk_heads < 1 )
- phy_s = sectno;
- else
- {
- phy_s = sectno%disk_spt;
- phy_h = sectno/disk_spt%disk_heads;
- phy_c = sectno/disk_spt/disk_heads;
- }
-
-#ifdef DEBUG
- fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n", sectno, phy_c, phy_h, phy_s);
-#endif
-
- ltrack = phy_c*disk_heads+phy_h;
- if( disk_spt > 1 && disk_spt <= MAXTRK
- && track_no != ltrack && ltrack != bad_track)
- {
- rv = phy_read(disk_drive, phy_c, phy_h, 1, disk_spt, buffer);
- if( rv == 0 )
- {
- track_no = ltrack;
- buf_len = disk_spt;
- }
- else
- bad_track = ltrack;
- }
- if( track_no == ltrack )
- return buffer + phy_s * 512;
-
- do
- {
- rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
- tries--;
- }
- while(rv && tries > 0);
- if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
- rv, disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
-
- if(rv) return 0; else return buffer;
-}
-
-#if defined(__MSDOS__) || defined(__STANDALONE__)
-phy_read(drive, cyl, head, sect, length, buffer)
-{
-#asm
- push bp
- mov bp,sp
-
- push ds
- pop es
-
- mov dl,[bp+2+_phy_read.drive]
- mov ch,[bp+2+_phy_read.cyl]
- mov dh,[bp+2+_phy_read.head]
- mov cl,[bp+2+_phy_read.sect]
- mov al,[bp+2+_phy_read.length]
- mov bx,[bp+2+_phy_read.buffer]
-
- mov ah,#$02
- int $13
- jc read_err
- mov ax,#0
-read_err:
-
- pop bp
-#endasm
-}
-#endif
-
-#endif
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index ed823a6..acdd168 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -27,7 +27,7 @@ static char minibuf[2] = " ";
struct t_cmd_list * cptr;
#ifdef __STANDALONE__
- printf("\r");
+ printf("\r\n");
#endif
init_prog();
@@ -151,23 +151,12 @@ void init_prog()
cpu_check();
mem_check();
+#ifndef NOMONITOR
printf("Processor: %s", x86_name);
if(x86_fpu) printf(" with FPU");
if(x86_emu) printf(" in protected mode");
- if(x86 > 1)
- {
- printf(", A20 gate ");
- if( a20_closed() )
- {
- open_a20();
- if( a20_closed() )
- printf("won't open!!");
- else
- printf("is now open");
- }
- else printf("is already open.");
- }
printf("\n");
+#endif
printf("There is %u bytes available", offt-sbrk(0));
printf(", %dk of boot memory", boot_mem_top/64);
diff --git a/bootblocks/monitor.h b/bootblocks/monitor.h
index 9d66f95..4e499f0 100644
--- a/bootblocks/monitor.h
+++ b/bootblocks/monitor.h
@@ -19,9 +19,6 @@ extern union REGS __argr;
#ifdef TARFLOPPY
#define SINGLEFS
-#define NOMONITOR
-#define NOCOMMAND
-#define MINI_BUF
#define open_file tar_open_file
#define rewind_file tar_rewind_file
@@ -32,9 +29,6 @@ extern union REGS __argr;
#ifdef MINFLOPPY
#define SINGLEFS
-#define NOMONITOR
-#define NOCOMMAND
-#define MINI_BUF
#define open_file min_open_file
#define rewind_file min_rewind_file
@@ -45,10 +39,6 @@ extern union REGS __argr;
#ifdef DOSFLOPPY
#define SINGLEFS
-#define NOMONITOR
-#define NOCOMMAND
-#define MINI_BUF
-#define MAXTRK 24
#define open_file dos_open_file
#define rewind_file dos_rewind_file
@@ -57,6 +47,11 @@ extern union REGS __argr;
#define read_block dos_read_block
#endif
+#ifdef SINGLEFS
+/* #define NOCOMMAND */
+#define NOMONITOR
+#endif
+
#ifdef __STANDALONE__
#undef putchar
#define putchar putch
diff --git a/bootblocks/standalone.c b/bootblocks/standalone.c
deleted file mode 100644
index 8344c64..0000000
--- a/bootblocks/standalone.c
+++ /dev/null
@@ -1,310 +0,0 @@
-
-#include <bios.h>
-#include <errno.h>
-#asm
-entry _int_80 ! Tell ld86 we really do need this file.
- ! then call the init stuff before main.
-
- loc 1 ! Make sure the pointer is in the correct segment
-auto_func: ! Label for bcc -M to work.
- .word _pre_main ! Pointer to the autorun function
- .word no_op ! Space filler cause segs are padded to 4 bytes.
- .text ! So the function after is also in the correct seg.
-#endasm
-
-void int_80();
-
-static void pre_main()
-{
- /* Set the int 0x80 pointer to here */
- __set_es(0);
- __doke_es(0x80*4+0, int_80);
- __doke_es(0x80*4+2, __get_cs());
- bios_coninit();
-}
-
-void int_80()
-{
-#asm
-SYS_EXIT=1
-SYS_FORK=2
-SYS_READ=3
-SYS_WRITE=4
-SYS_OPEN=5
-SYS_CLOSE=6
-SYS_CHDIR=12
-SYS_LSEEK=19
-ENOSYS=38
-
- push es
- push si
- push di
- push dx
- push cx
- push bx
- cmp ax,#SYS_READ
- jne L1
- call _func_read
- jmp L0
-L1:
- cmp ax,#SYS_WRITE
- jne L2
- call _func_write
- jmp L0
-L2:
- cmp ax,#SYS_LSEEK
- jne L3
- call _func_lseek
- jmp L0
-L3:
- cmp ax,#SYS_EXIT
- jne L4
- call _func_exit
- jmp L0
-L4:
- mov ax,#-ENOSYS
-L0:
- pop bx
- pop cx
- pop dx
- pop di
- pop si
- pop es
- iret
-#endasm
-}
-
-func_lseek() { return -38; }
-
-func_write(bx,cx,dx,di,si,es)
-int bx,dx;
-char * cx;
-{
- register int v, c;
- if(bx == 1 || bx == 2)
- {
- for(v=dx; v>0; v--)
- {
- c= *cx++;
- if( c == '\n') bios_putc('\r');
- bios_putc(c);
- }
- return dx;
- }
- return -EBADF;
-}
-
-func_read(bx,cx,dx,di,si,es)
-int bx,dx;
-char * cx;
-{
- if(bx == 0) return read_line(cx, dx);
- return -EBADF;
-}
-
-read_line(buf, len)
-char * buf;
-int len;
-{
- int ch;
- int pos=0;
-
- if( len == 1 )
- {
- buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80));
- return 1;
- }
-
- for(ch=0;;)
- {
- if(ch != '\003')
- {
- ch = bios_getc();
- if( pos == 0 && (ch&0xFF) == 0 )
- {
- buf[0] = ((ch>>8)|0x80);
- return 1;
- }
- ch &= 0x7F;
- }
- if( ch == '\r' )
- {
- bios_putc('\r'); bios_putc('\n');
- buf[pos++] = '\n';
- return pos;
- }
- if( ch >= ' ' && ch != 0x7F && pos < len-1)
- bios_putc(buf[pos++] = ch);
- else if( (ch == '\003' || ch == '\b') && pos > 0 )
- {
- bios_putc('\b'); bios_putc(' '); bios_putc('\b');
- pos--;
- }
- else if( ch == '\003' )
- return 0;
- else
- bios_putc('\007');
- }
-}
-
-#define CTRL(x) ((x)&0x1F)
-static int last_attr = 0x07;
-static int con_mode;
-static int con_size = 0x184F;
-static int con_colour = 0;
-
-bios_coninit()
-{
-#asm
- mov ax,#$0F00
- int $10
- mov _con_mode,ax
-#endasm
- if( (con_mode &0xFF) > 39 ) con_size = (con_size&0xFF00) + (con_mode&0xFF);
- if( (con_mode&0xFF00) != 0x700)
- con_colour = 1;
-}
-
-bios_putc(c)
-int c;
-{
-static char tbuf[3];
-static int tcnt=0;
- if(tcnt)
- {
- tbuf[tcnt++] = c;
- if( tcnt < 3 && (tbuf[0] != CTRL(']') || tbuf[1] < '`' || tbuf[1] > 'p'))
- return;
- if( tbuf[0] == CTRL('P') )
- {
- if( tbuf[1] >= 32 && tbuf[1] <= 56
- && tbuf[2] >= 32 && tbuf[2] <= 111 )
- asm_cpos((tbuf[1]-32), (tbuf[2]-32));
- }
- else
- {
- if( tbuf[1] >= '`' )
- last_attr = ( (tbuf[1]&0xF) | (last_attr&0xF0));
- else
- last_attr = ( (tbuf[2]&0xF) | ((tbuf[1]&0xF)<<4));
-
- if( !con_colour )
- last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70);
- }
- tcnt=0;
- return;
- }
- if( c & 0xE0 ) { asm_colour(last_attr) ; asm_putc(c); }
- else switch(c)
- {
- case CTRL('L'):
- asm_cpos(0,0);
- asm_cls();
- break;
- case CTRL('P'):
- case CTRL(']'):
- tbuf[tcnt++] = c;
- break;
- default:
- asm_putc(c);
- break;
- }
- return;
-}
-
-static asm_putc(c)
-{
-#asm
-#if !__FIRST_ARG_IN_AX__
- mov bx,sp
- mov ax,[bx+2]
-#endif
- mov ah,#$0E
- mov bx,#7
- int $10
-#endasm
-}
-
-static asm_colour(c)
-{
-#asm
-#if __FIRST_ARG_IN_AX__
- mov bx,ax
-#else
- mov bx,sp
- mov bx,[bx+2]
-#endif
- mov ah,#$08
- int $10
- mov ah,#$09
- mov cx,#1
- int $10
-#endasm
-}
-
-static asm_cls()
-{
-#asm
- push bp ! Bug in some old BIOS's
- !mov ax,#$0500
- !int $10
- mov ax,#$0600
- mov bh,_last_attr
- mov cx,#$0000
- mov dx,_con_size
- int $10
- pop bp
-#endasm
-}
-
-static asm_cpos(r,c)
-{
-#asm
-#if __FIRST_ARG_IN_AX__
- mov bx,sp
- mov dh,al
- mov ax,[bx+2]
- mov dl,al
-#else
- mov bx,sp
- mov ax,[bx+2]
- mov dh,al
- mov ax,[bx+4]
- mov dl,al
-#endif
- mov ah,#$02
- mov bx,#7
- int $10
-#endasm
-}
-
-bios_getc()
-{
-#asm
- xor ax,ax
- int $16
-#endasm
-}
-
-static void be_safe()
-{
-#asm
- iret
-#endasm
-}
-
-func_exit(bx,cx,dx,di,si,es) /* AKA reboot! */
-{
- __set_es(0);
- __doke_es(0xE6*4+2,__get_cs());
- __doke_es(0xE6*4+0,be_safe);
-#asm
- mov ax,#$FFFF
- int $E6 ! Try to exit DOSEMU
- mov ax,#$0040 ! If we get here we're not in dosemu.
- mov es,ax
- seg es
- mov [$72],#$1234 ! Warm reboot.
- jmpi $0000,$FFFF
-#endasm
-}
diff --git a/bootblocks/tich.s b/bootblocks/tich.s
deleted file mode 100644
index ce21e4a..0000000
--- a/bootblocks/tich.s
+++ /dev/null
@@ -1,39 +0,0 @@
-!
-
-org 0
- call chk !This chunk allows this code to exist at _any_ click
-chk:
- pop ax
- mov cl,#4
- shr ax,cl
- mov bx,cs
- add ax,bx
- push ax
- mov bx,#going
- push bx
- retf
-going:
- mov ds,ax
- mov es,ax
-
-! Print 'mesg'
- mov ah,#0x03 ! read cursor pos
- xor bh,bh
- int 0x10
-
- mov cx,#(emesg-mesg)
- mov bp,#mesg
- mov bx,#$7 ! page 0, attribute 7 (normal)
- mov ax,#$1301 ! write string, move cursor
- int $10
-
-nogood:
- j nogood
-
-mesg:
-.ascii "Hello world"
-emesg:
-
-! Floppies aren't supposed to need this, oh well.
-org 510
- .word $AA55
diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c
deleted file mode 100644
index cfa1e93..0000000
--- a/bootblocks/trk_buf.c
+++ /dev/null
@@ -1,390 +0,0 @@
-
-#include "monitor.h"
-
-#ifndef MINI_BUF
-
-/* #define DEBUG 1 /**/
-
-int disk_drive = 0;
-int disk_spt = 7;
-int disk_heads = 0;
-int disk_cyls = 0;
-long disk_partition_offset = 0;
-
-int check_motor = 1;
-
-static int last_drive = -1;
-static int data_len = 0;
-static long data_trk1 = 0;
-static char * data_buf1 = 0;
-static long data_trk2 = 0;
-static char * data_buf2 = 0;
-
-static long bad_track = -1; /* Track number of last unsuccesful read */
-
-static long get_dpt();
-
-void reset_disk()
-{
-#ifdef DEBUG
- fprintf(stderr, "Reset Disk: ");
-#endif
- if( data_buf1 ) free(data_buf1);
- if( data_buf2 ) free(data_buf2);
- data_buf1 = data_buf2 = 0;
- last_drive = disk_drive;
- bad_track = -1;
-
- disk_spt = 7; /* Defaults for reading floppy boot area. */
- disk_heads = 0;
- disk_cyls = 0;
-
- if( !(disk_drive & 0x80 ) )
- {
-#ifdef __STANDALONE__
- if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 )
- {
- disk_spt = __argr.x.si;
- disk_heads = 2;
- disk_cyls = 80;
- }
-#endif
-
- /* Floppy -> no partitions */
- /* Even if there were we couldn't deal with it anyway! */
- disk_partition_offset = 0;
- }
-#if defined(__MSDOS__) || defined(__STANDALONE__)
- else
- {
- /* Hard disk, get parameters from bios */
- long dpt;
- int v;
-
-#ifdef __STANDALONE__
- if( disk_partition_offset == 0 && disk_drive == __argr.h.dl )
- {
- disk_partition_offset = __argr.x.cx + ((long)__argr.h.dh<<16);
- }
-#endif
-
- dpt = get_dpt(disk_drive);
- v = ((dpt>>16) & 0xFF);
- if( v != 0xFF && v > (disk_drive&0x7F) )
- {
- disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */
- if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */
- disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */
- disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1;
-
- /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be
- * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl.
- */
- }
- }
-#endif
-
-#ifdef DEBUG
- fprintf(stderr, "%d/%d/%d\n", disk_spt, disk_heads, disk_cyls);
-#endif
-}
-
-char * read_lsector(sectno)
-long sectno;
-{
- int rv;
-
- int phy_s = 1;
- int phy_h = 0;
- int phy_c = 0;
-
- rv = 0;
- if( disk_drive != last_drive ) rv = 1;
- else if( check_motor ) rv = ( motor_running() == 0 );
- else if( sectno == 0 ) rv = 1;
- if( rv ) reset_disk();
-
- if( disk_partition_offset > 0 )
- sectno += disk_partition_offset;
-
- if( disk_spt < 0 || disk_spt > 63 || disk_heads < 1 )
- {
- phy_s = sectno;
-#if DEBUG > 1
- fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n",
- sectno, phy_c, phy_h, phy_s+1);
-#endif
- }
- else
- {
- phy_s = sectno%disk_spt;
- phy_h = sectno/disk_spt%disk_heads;
- phy_c = sectno/disk_spt/disk_heads;
-
-#if DEBUG > 1
- fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n",
- sectno, phy_c, phy_h, phy_s+1);
-#endif
-
- if( fetch_track_buf(phy_c, phy_h, phy_s) >= 0 )
- return data_buf1 + (phy_s % data_len) * 512;
- }
-
- data_len = -1; /* Zap the cache */
- if( data_buf1 == 0 )
- data_buf1 = malloc(512);
- if( data_buf1 == 0 )
- {
- printf("Cannot allocate memory for disk read!!!\n");
- return 0;
- }
-
-#ifdef DEBUG
- fprintf(stderr, "phy_read(%d,%d,%d,%d,%d,0x%x)\n",
- disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
-#endif
-
- do
- {
- int v,tries = 6;
- do
- {
- rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
- tries--;
- }
- while(rv && tries > 0);
- if( rv )
- {
- printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\nRetry:",
- rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
- fflush(stdout);
-
- v = phy_reset(disk_drive);
- v = (getch()&0x7F);
- printf("\n");
- if( v == 3 || v == 27 ) break;
- }
- }
- while(rv);
-
- check_motor = motor_running();
-
- if(rv) return 0; else return data_buf1;
-}
-
-fetch_track_buf(phy_c, phy_h, phy_s)
-int phy_c, phy_h, phy_s;
-{
- long trk_no, t;
- char * p;
- int tries = 6;
- int rv, nlen;
-
- /* Big tracks get us short of memory so limit it. */
- nlen = (disk_spt-1)/24;
- nlen = (disk_spt+nlen)/(nlen+1);
- /*
- trk_no = (long)phy_c*disk_heads*4+phy_h*4+phy_s/nlen+1;
- */
-
- trk_no = (long)(phy_c*disk_heads+phy_h)*((disk_spt+4)/nlen)+phy_s/nlen+1;
-
-#if DEBUG > 2
- fprintf(stderr, "Info len=%d,%d trk=%ld,%ld,%ld\n",
- data_len,nlen, trk_no,data_trk1,data_trk2);
-#endif
-
- if( data_len != nlen )
- {
- if( data_buf1 ) free(data_buf1);
- if( data_buf2 ) free(data_buf2);
- data_buf1 = data_buf2 = 0;
- data_len = nlen;
- }
- if( trk_no == bad_track ) return -1;
-
- if( data_buf1 && trk_no == data_trk1 ) return 0;
-
- /* Two cases:
- * 1) buffer2 has the one we want, need to swap to make it most recent
- * 2) Neither has it, need to swap to overwrite least recent.
- */
-
- /* But sequential reads may spoil this so don't swap if we are shifting
- * to the next track.
- */
-
- if( trk_no == data_trk2 || trk_no != data_trk1 + 1 )
- {
- p = data_buf1; data_buf1 = data_buf2; data_buf2 = p;
- t = data_trk1; data_trk1 = data_trk2; data_trk2 = t;
- }
-
- /* The other one right ? */
- if( data_buf1 && trk_no == data_trk1 ) return 0;
-
- /* If we get here we have to do a physical read ... */
- /* into data_buf1. */
-
- if( data_buf1 == 0 )
- {
- data_buf1 = malloc(disk_spt*512);
-
-#ifdef DEBUG
- if( data_buf1 )
- fprintf(stderr, "Allocated buffer to %d\n", data_buf1);
- else
- fprintf(stderr, "Failed to allocated buffer.\n");
-#endif
- }
- if( data_buf1 == 0 )
- {
- /* Is buf2 allocated ? Yes take it! */
- data_buf1 = data_buf2; data_buf2 = 0; data_trk2 = -1;
- }
-
- data_trk1 = -1;
-
- /* Not enough memory for track read. */
- if( data_buf1 == 0 ) return -1;
-
-#ifdef DEBUG
- fprintf(stderr, "phy_read(%d,%d,%d,%d,%d,0x%x)\n",
- disk_drive, phy_c, phy_h, phy_s/data_len*data_len+1, data_len, data_buf1);
-#endif
-
- do /* the physical read */
- {
- rv = phy_read(disk_drive, phy_c, phy_h, phy_s/data_len*data_len+1, data_len,
- data_buf1);
- tries--;
- }
- while(rv && tries > 0);
- if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
- rv, disk_drive, phy_c, phy_h, phy_s/data_len+1, data_len, data_buf1);
-
- check_motor = motor_running();
-
- /* Disk error, it'll try one at a time, _very_ slowly! */
- if(rv)
- {
- bad_track = trk_no;
- return -1;
- }
-
- /* Yes! */
- data_trk1 = trk_no;
- return 0;
-}
-
-#if defined(__MSDOS__) || defined(__STANDALONE__)
-phy_read(drive, cyl, head, sect, length, buffer)
-{
-#asm
- push bp
- mov bp,sp
-
- push es
- push ds
- pop es
-
- mov dl,[bp+2+_phy_read.drive]
- mov ch,[bp+2+_phy_read.cyl]
- mov dh,[bp+2+_phy_read.head]
- mov bx,[bp+2+_phy_read.buffer]
-
- mov ax,[bp+2+_phy_read.cyl] ! Bits 10-11 of cylinder, AMI BIOS.
- mov cl,#4
- sar ax,cl
- and al,#$C0
- xor dh,al
-
- mov cl,[bp+2+_phy_read.sect]
- and cl,#$3F
- mov ax,[bp+2+_phy_read.cyl] ! Bits 8-9 of cylinder.
- sar ax,#1
- sar ax,#1
- and al,#$C0
- or cl,al
-
- mov al,[bp+2+_phy_read.length]
- mov ah,#$02
- int $13
- jc read_err
- mov ax,#0
-read_err:
- xchg ah,al
- xor ah,ah
-
- pop es
- pop bp
-#endasm
-}
-
-long
-get_dpt(drive)
-{
-#asm
- push bp
- mov bp,sp
-
- push di
- push es
-
- mov dl,[bp+2+_get_dpt.drive]
-
- mov ah,#$08
- int $13
- jnc func_ok
- mov cx,ax
- mov dx,#-1
-func_ok:
- mov ax,cx
-
- pop es
- pop di
- pop bp
-#endasm
-}
-
-phy_reset(drive)
-{
-#asm
- push bp
- mov bp,sp
-
- push di
- push es
-
- mov dl,[bp+2+_phy_reset.drive]
-
- mov ah,#$08
- int $13
- jnc reset_ok
- mov cx,ax
- mov dx,#-1
-reset_ok:
- mov ax,cx
-
- pop es
- pop di
- pop bp
-#endasm
-}
-
-motor_running()
-{
-#asm
- push es
- mov ax,#$40
- mov es,ax
- seg es
- mov al,[$3f]
- xor ah,ah
- and al,#$0F
- pop es
-#endasm
-}
-#endif
-
-#endif
diff --git a/copt/copt.c b/copt/copt.c
index cc31541..35588d3 100644
--- a/copt/copt.c
+++ b/copt/copt.c
@@ -183,7 +183,7 @@ static char *readline(FILE *fp)
* has been found in the first column of the input line. All lines with the
* 'comment' character in the first position will be skipped.
*/
-static struct line_s *readlist(FILE *fp, char quit, char comment)
+static struct line_s *readlist(FILE *fp, int quit, int comment)
{
struct line_s *lp;
struct line_s *first_line = NULL;
@@ -293,7 +293,7 @@ static void clearpattern(void)
/*
* Read input file
*/
-static void readinfile(char *filename, char comment)
+static void readinfile(char *filename, int comment)
{
FILE *fp;
diff --git a/elksemu/elks_sys.c b/elksemu/elks_sys.c
index 75ee3da..a886e99 100644
--- a/elksemu/elks_sys.c
+++ b/elksemu/elks_sys.c
@@ -404,7 +404,7 @@ static int elks_getgid(int bx,int cx,int dx,int di,int si)
*
* For now we run elksemu ourselves and do token attempts at binary checking.
*
- * Of course with the Patch in the Linux kernel we could just run the exe.
+ * Of course if the kernel misc module is confiured we could just run the exe.
*/
#define sys_execve elks_execve
static int elks_execve(int bx,int cx,int dx,int di,int si)
diff --git a/ld/objdump86.c b/ld/objdump86.c
index 71e5e62..4979a1a 100644
--- a/ld/objdump86.c
+++ b/ld/objdump86.c
@@ -318,7 +318,7 @@ read_sectheader()
cpos = ftell(ifd);
fseek(ifd, filepos+str_off, 0);
- fread(symtab, 1, (int)str_len, ifd);
+ fread(symtab, 1, (unsigned int)str_len, ifd);
fseek(ifd, cpos, 0);
if( !display_mode )
diff --git a/libc/bios/Makefile b/libc/bios/Makefile
index cd97308..692d535 100644
--- a/libc/bios/Makefile
+++ b/libc/bios/Makefile
@@ -14,7 +14,11 @@ BOBJ=bios_putch.o bios_getch.o bios_getche.o bios_cputs.o bios_kbhit.o \
CSRC=bios_min.c
COBJ=bios_putc.o bios_getc.o
-OBJ=$(AOBJ) $(BOBJ) $(COBJ) time.o fileops.o fs_dos.o rawio.o vt52.o ansi.o
+DSRC=bios_disk.c
+DOBJ=bios_disk_read.o bios_disk_write.o bios_disk_reset.o bios_get_dpt.o
+
+OBJ=$(AOBJ) $(BOBJ) $(COBJ) $(DOBJ) \
+ time.o fileops.o fs_dos.o rawio.o vt52.o ansi.o
CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
@@ -32,6 +36,10 @@ $(LIBC)($(BOBJ)): $(BSRC)
$(LIBC)($(COBJ)): $(CSRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(AR) $(ARFLAGS) $@ $*.o
+
+$(LIBC)($(DOBJ)): $(DSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(AR) $(ARFLAGS) $@ $*.o
else
all:
@:
diff --git a/libc/bios/bios_disk.c b/libc/bios/bios_disk.c
new file mode 100644
index 0000000..e0d9961
--- /dev/null
+++ b/libc/bios/bios_disk.c
@@ -0,0 +1,158 @@
+
+#if !__FIRST_ARG_IN_AX__
+#ifdef __AS386_16__
+
+#include <bios.h>
+#include <errno.h>
+
+#ifdef L_bios_disk_read
+_bios_disk_read(drive, cyl, head, sect, length, buffer)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push es
+ push ds
+ pop es
+
+ mov dl,[bp+2+__bios_disk_read.drive]
+ mov ch,[bp+2+__bios_disk_read.cyl]
+ mov dh,[bp+2+__bios_disk_read.head]
+ mov bx,[bp+2+__bios_disk_read.buffer]
+
+#if 0
+ mov ax,[bp+2+__bios_disk_read.cyl] ! Bits 10-11 of cylinder, AMI BIOS.
+ mov cl,#4
+ sar ax,cl
+ and al,#$C0
+ xor dh,al
+#endif
+
+ mov cl,[bp+2+__bios_disk_read.sect]
+ and cl,#$3F
+ mov ax,[bp+2+__bios_disk_read.cyl] ! Bits 8-9 of cylinder.
+ sar ax,#1
+ sar ax,#1
+ and al,#$C0
+ or cl,al
+
+ mov al,[bp+2+__bios_disk_read.length]
+ mov ah,#$02
+ int $13
+ jc read_err1
+ mov ax,#0
+read_err1:
+ xchg ah,al
+ xor ah,ah
+
+ pop es
+ pop bp
+#endasm
+}
+#endif
+
+#ifdef L_bios_disk_write
+_bios_disk_write(drive, cyl, head, sect, length, buffer)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push es
+ push ds
+ pop es
+
+ mov dl,[bp+2+__bios_disk_write.drive]
+ mov ch,[bp+2+__bios_disk_write.cyl]
+ mov dh,[bp+2+__bios_disk_write.head]
+ mov bx,[bp+2+__bios_disk_write.buffer]
+
+#if 0
+ mov ax,[bp+2+__bios_disk_write.cyl] ! Bits 10-11 of cylinder, AMI BIOS.
+ mov cl,#4
+ sar ax,cl
+ and al,#$C0
+ xor dh,al
+#endif
+
+ mov cl,[bp+2+__bios_disk_write.sect]
+ and cl,#$3F
+ mov ax,[bp+2+__bios_disk_write.cyl] ! Bits 8-9 of cylinder.
+ sar ax,#1
+ sar ax,#1
+ and al,#$C0
+ or cl,al
+
+ mov al,[bp+2+__bios_disk_write.length]
+ mov ah,#$03
+ int $13
+ jc read_err2
+ mov ax,#0
+read_err2:
+ xchg ah,al
+ xor ah,ah
+
+ pop es
+ pop bp
+#endasm
+}
+#endif
+
+#ifdef L_bios_get_dpt
+long
+_bios_get_dpt(drive)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push di
+ push es
+
+ mov dl,[bp+2+__bios_get_dpt.drive]
+
+ mov ah,#$08
+ int $13
+ jnc func_ok
+ mov cx,ax
+ mov dx,#-1
+func_ok:
+ mov ax,cx
+
+ pop es
+ pop di
+ pop bp
+#endasm
+}
+#endif
+
+#ifdef L_bios_disk_reset
+_bios_disk_reset(drive)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push di
+ push es
+
+ mov dl,[bp+2+__bios_disk_reset.drive]
+
+ mov ah,#$08
+ int $13
+ jnc reset_ok
+ mov cx,ax
+ mov dx,#-1
+reset_ok:
+ mov ax,cx
+
+ pop es
+ pop di
+ pop bp
+#endasm
+}
+#endif
+
+#endif
+#endif
diff --git a/libc/bios/fs_dos.c b/libc/bios/fs_dos.c
index 28ee962..b826d45 100644
--- a/libc/bios/fs_dos.c
+++ b/libc/bios/fs_dos.c
@@ -1,13 +1,14 @@
+#ifdef DEBUG
#include <stdio.h>
+#endif
+
#include <ctype.h>
#include <malloc.h>
#include <errno.h>
#include "io.h"
#include "rawio.h"
-#define DONT_BUFFER_FAT
-
#define DOS_SECT(P) get_uint(P,0x0B)
#define DOS_CLUST(P) get_byte(P,0x0D)
#define DOS_RESV(P) get_uint(P,0x0E)
@@ -22,6 +23,7 @@
#define DOS4_MAXSECT(P) get_long(P,0x20)
#define DOS4_PHY_DRIVE(P) get_byte(P,0x24)
#define DOS4_SERIAL(P) get_long(P,0x27)
+#define DOS4_FATTYPE(P) get_uint(P,0x39)
/* These assume alignment is not a problem */
#define get_byte(P,Off) *((unsigned char*)((char*)(P)+(Off)))
@@ -33,15 +35,11 @@ static int dir_nentry, dir_sect;
static int dos_clust0, dos_spc, dos_fatpos;
static int last_serial = 0;
-#ifdef BUFFER_FAT
-static char * fat_buf = 0;
-#endif
-
struct filestatus {
char fname[12];
unsigned short first_cluster;
unsigned short cur_cluster;
- unsigned short sector_no;
+ unsigned short sector_no; /* Max filesize = 32M */
long file_length;
};
@@ -61,11 +59,10 @@ int mode;
char conv_name[12];
char *d, *s;
int i;
- int dodir = 0;
struct filestatus* cur_file;
#ifdef DEBUG
- printf("fsdos_open_file(%x, %s, %d, %d, %d)\n",
+ fprintf(stderr, "fsdos_open_file(%x, %s, %d, %d, %d)\n",
iob, fname, flags, mode, sizeof(iob));
#endif
iob->block_read = fsdos_read_block;
@@ -74,9 +71,6 @@ int mode;
/* Get the superblock */
if( read_bootblock() < 0 ) return -1;
- if(strcmp(fname, ".") == 0)
- dodir = 1;
- else
{
/* Convert the name to MSDOS directory format */
strcpy(conv_name, " ");
@@ -97,38 +91,7 @@ int mode;
}
}
#ifdef DEBUG
- printf("fsdos_open_file: converted filename=<%s>\n", conv_name);
-#endif
-
-#ifdef BUFFER_FAT
- rawio_read_sector(0, sect);
-
- if( !dodir )
- {
- /* Read in and buffer the FAT */
- if( fat_buf ) free(fat_buf);
- fat_buf = malloc(DOS_FATLEN(sect) * 512);
- if( fat_buf == 0 )
- {
- errno = ENOMEM;
- return -1;
- }
- else
- {
- int fatsec = DOS_RESV(sect);
- int nsec = DOS_FATLEN(sect);
-
- for(i=0; i<nsec; i++)
- {
- if (rawio_read_sector(fatsec+i, sect) == 0)
- {
- errno = EIO;
- return -1;
- }
- memcpy(fat_buf+i*512, sect, 512);
- }
- }
- }
+ fprintf(stderr, "fsdos_open_file: converted filename=<%s>\n", conv_name);
#endif
/* Scan the root directory for the file */
@@ -141,37 +104,7 @@ int mode;
return -1;
}
d = s + (i%16)*32;
- if( dodir )
- {
- char dtime[20];
- char lbuf[90];
- *lbuf = 0;
-
- sprintf(dtime, " %02d/%02d/%04d %02d:%02d",
- (get_uint(d,24)&0x1F),
- ((get_uint(d,24)>>5)&0xF),
- ((get_uint(d,24)>>9)&0x7F)+1980,
- ((get_uint(d,22)>>11)&0x1F),
- ((get_uint(d,22)>>5)&0x3F)
- );
- if( *d > ' ' && *d <= '~' ) switch(d[11]&0x18)
- {
- case 0:
- printf("%-8.8s %-3.3s %10ld%s\n", d, d+8, get_long(d,28), dtime);
- break;
- case 0x10:
- printf("%-8.8s %-3.3s <DIR> %s\n", d, d+8, dtime);
- break;
- case 8:
- if( (d[11] & 7) == 0 )
- printf("%-11.11s <LBL> %s\n", d, dtime);
- break;
- }
-#if 0
- if( more_strn(lbuf, sizeof(lbuf)) < 0 ) break;
-#endif
- }
- else if( memcmp(d, conv_name, 11) == 0 && (d[11]&0x18) == 0 )
+ if( memcmp(d, conv_name, 11) == 0 && (d[11]&0x18) == 0 )
{ /* Name matches and is normal file */
#ifdef DEBUG
@@ -233,11 +166,6 @@ ioblock* iob;
free(cur_file);
iob->context = NULL;
-#ifdef BUFFER_FAT
- if( fat_buf ) free(fat_buf);
- fat_buf = 0;
-#endif
-
rawio_reset_disk();
return 0;
}
@@ -278,7 +206,9 @@ long block; /* ignored for now */
#endif
if (iob == NULL || iob->context == NULL)
{
+#ifdef DEBUG
fprintf(stderr, "rb: no context\n");
+#endif
errno = EBADF;
return -1;
}
@@ -345,9 +275,6 @@ long block; /* ignored for now */
unsigned int val, val2;
val = cur_file->cur_cluster + (cur_file->cur_cluster>>1);
-#ifdef BUFFER_FAT
- val2 = get_uint(fat_buf, val);
-#else
if (rawio_read_sector(dos_fatpos+(val/512), sect) <= 0) return -1;
if( val%512 == 511 )
{
@@ -357,7 +284,6 @@ long block; /* ignored for now */
}
else
val2 = get_uint(sect, (val%512));
-#endif
if( odd ) val2>>=4;
@@ -380,7 +306,7 @@ static int read_bootblock()
int rv, media_byte = 0;
#ifdef DEBUG
- printf("fs_dos:read_bootblock:\n");
+ fprintf(stderr, "fs_dos:read_bootblock:\n");
#endif
if (rawio_read_sector(1, sect) <= 0) return -1;
media_byte = *(unsigned char*)sect;
@@ -412,7 +338,7 @@ static int read_bootblock()
}
#ifdef DEBUG
- printf("read_bootblock: heads(%d), spt(%d), dir_sect(%d)\n",
+ fprintf(stderr, "read_bootblock: heads(%d), spt(%d), dir_sect(%d)\n",
rawio_disk_heads,
rawio_disk_spt,
dir_sect);
diff --git a/libc/bios/rawio.c b/libc/bios/rawio.c
index 1bb0e4d..2da573b 100644
--- a/libc/bios/rawio.c
+++ b/libc/bios/rawio.c
@@ -2,7 +2,10 @@
* rawio.c - plagiarised from ../../bootblocks/trk_buf.c
*/
+#ifdef DEBUG
#include <stdio.h>
+#endif
+
#include <bios.h>
#include <ctype.h>
#include <malloc.h>
@@ -124,18 +127,24 @@ char* buffer;
data_buf1 = malloc(512);
if( data_buf1 == 0 )
{
+#ifdef DEBUG
fprintf(stderr, "Cannot allocate memory for disk read!!!\n");
+#endif
return 0;
}
+#ifdef DEBUG
fprintf(stderr, "WARNING: Single sector read\n");
+#endif
do
{
rv = rawio_phy_read(rawio_disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
tries--;
+#ifdef DEBUG
if( rv ) fprintf(stderr, "Error in phy_read(%d,%d,%d,%d,%d,%d);\n",
rawio_disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
+#endif
}
while(rv && tries > 0);
@@ -239,8 +248,10 @@ int phy_c, phy_h, phy_s;
rv = rawio_phy_read(rawio_disk_drive, phy_c, phy_h, phy_s/data_len+1, data_len,
data_buf1);
tries--;
+#ifdef DEBUG
if( rv ) fprintf(stderr, "Error in phy_read(%d,%d,%d,%d,%d,%d);\n",
rawio_disk_drive, phy_c, phy_h, phy_s/data_len+1, data_len, data_buf1);
+#endif
}
while(rv && tries > 0);
diff --git a/libc/include/bios.h b/libc/include/bios.h
index 20aa5ca..8c60d34 100644
--- a/libc/include/bios.h
+++ b/libc/include/bios.h
@@ -22,6 +22,7 @@ int __peek_es __P((unsigned int off));
int __deek_es __P((unsigned int off));
#define movedata __movedata
+long _bios_get_dpt(drive);
#ifdef __LIBC__
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index a724a4c..245b1c0 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -15,8 +15,9 @@ extern unsigned char __ctype[];
#define __CT_p 0x20 /* punctuation */
#define __CT_x 0x40 /* hexadecimal */
-#define toupper(c) (islower(c) ? (c)^0x20 : (c))
-#define tolower(c) (isupper(c) ? (c)^0x20 : (c))
+/* Define these as simple old style ascii versions */
+#define toupper(c) (((c)>='a'&&(c)<='z') ? (c)^0x20 : (c))
+#define tolower(c) (((c)>='A'&&(c)<='Z') ? (c)^0x20 : (c))
#define _toupper(c) ((c)^0x20)
#define _tolower(c) ((c)^0x20)
#define toascii(c) ((c)&0x7F)
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index fd10923..cbdacc3 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -111,11 +111,14 @@ extern int fputc __P((int, FILE*));
extern int fclose __P((FILE*));
extern int fflush __P((FILE*));
extern char *fgets __P((char*, size_t, FILE*));
-extern FILE *__fopen __P((char*, int, FILE*, char*));
-#define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode))
-#define freopen(__file, __mode, __fp) __fopen((__file), -1, (__fp), (__mode))
-#define fdopen(__file, __mode) __fopen((char*)0, (__file), (FILE*)0, (__mode))
+extern FILE *fopen __P((char*, char*));
+extern FILE *fdopen __P((int, char*));
+extern FILE *freopen __P((char*, char*, FILE*));
+
+#ifdef __LIBC__
+extern FILE *__fopen __P((char*, int, FILE*, char*));
+#endif
extern int fputs __P((char*, FILE*));
extern int puts __P((char*));
diff --git a/libc/misc/Makefile b/libc/misc/Makefile
index 74a2637..b779802 100644
--- a/libc/misc/Makefile
+++ b/libc/misc/Makefile
@@ -10,7 +10,7 @@ ESRC=atexit.c
EOBJ=on_exit.o atexit.o __do_exit.o
GOBJ=atoi.o atol.o ltoa.o ltostr.o \
- ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \
+ ctype.o ctypefn.o qsort.o bsearch.o rand.o lsearch.o getopt.o \
itoa.o cputype.o strtol.o crypt.o
UOBJ=getenv.o putenv.o popen.o system.o setenv.o getcwd.o tmpnam.o
diff --git a/libc/misc/crypt.c b/libc/misc/crypt.c
index db69325..be51948 100644
--- a/libc/misc/crypt.c
+++ b/libc/misc/crypt.c
@@ -6,7 +6,7 @@
/*
* I've:
* Compared the TEA implementation to a reference source - OK
- * Noted the cycles count at 64 is twice the suggested value.
+ * Reduced the cycles count from 64 to 32 (the suggested value)
* Changed the types of 'n' and 'i' for better code with bcc.
* Removed a possible overrun of rkey by looping the values, it's now
* possible to _choose_ every bit of the 128bit PW with a 32 character word.
@@ -26,7 +26,7 @@ crypt(const char * key, const char * salt)
k is the key, v is the data to be encrypted. */
unsigned long v[2], sum=0, delta=0x9e3779b9, k[4];
- int n=64, i, j;
+ int n=32, i, j;
static char rkey[16];
/* Our constant string will be a string of zeros .. */
diff --git a/libc/misc/ctype.c b/libc/misc/ctype.c
index 0425f00..d684e15 100644
--- a/libc/misc/ctype.c
+++ b/libc/misc/ctype.c
@@ -9,9 +9,6 @@
#include <ctype.h>
-#undef toupper
-#undef tolower
-
unsigned char __ctype[257] =
{
0, /* -1 */
@@ -56,14 +53,3 @@ unsigned char __ctype[257] =
__CT_p, __CT_p, __CT_p, __CT_c /* 0x7C..0x7F */
};
-int toupper(c)
-int c;
-{
- return(islower(c) ? (c ^ 0x20) : (c));
-}
-
-int tolower(c)
-int c;
-{
- return(isupper(c) ? (c ^ 0x20) : (c));
-}
diff --git a/libc/misc/ctypefn.c b/libc/misc/ctypefn.c
new file mode 100644
index 0000000..921da31
--- /dev/null
+++ b/libc/misc/ctypefn.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+
+/*
+ * CTYPE.C Character classification and conversion
+ */
+
+#include <ctype.h>
+
+#undef toupper
+#undef tolower
+
+int toupper(c)
+int c;
+{
+ return(islower(c) ? (c ^ 0x20) : (c));
+}
+
+int tolower(c)
+int c;
+{
+ return(isupper(c) ? (c ^ 0x20) : (c));
+}
diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile
index 0fd8d97..9e96427 100644
--- a/libc/stdio/Makefile
+++ b/libc/stdio/Makefile
@@ -7,9 +7,9 @@ CFLAGS=$(CCFLAGS) $(LIBDEFS) -DFLOATS
endif
ASRC=stdio.c
-AOBJ=_stdio_init.o fputc.o fgetc.o fflush.o fgets.o gets.o fputs.o \
- puts.o fread.o fwrite.o fopen.o fclose.o fseek.o rewind.o ftell.o \
- setbuffer.o setvbuf.o ungetc.o
+AOBJ=_stdio_init.o fputc.o fgetc.o fflush.o fgets.o gets.o fputs.o \
+ puts.o fread.o fwrite.o fopen.o fdopen.o freopen.o __fopen.o \
+ fclose.o fseek.o rewind.o ftell.o setbuffer.o setvbuf.o ungetc.o
PSRC=printf.c
POBJ=printf.o sprintf.o fprintf.o vprintf.o vsprintf.o vfprintf.o
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 6b0dba0..b8e68a5 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -582,9 +582,39 @@ FILE * fp;
#endif
#ifdef L_fopen
+FILE *
+fopen(file, mode)
+char * file;
+char * mode;
+{
+ return __fopen(file, -1, (FILE*)0, mode);
+}
+#endif
+
+#ifdef L_freopen
+FILE *
+freopen(file, mode, fp)
+char * file;
+char * mode;
+FILE * fp;
+{
+ return __fopen(file, -1, fp, mode);
+}
+#endif
+
+#ifdef L_fdopen
+FILE *
+fdopen(file, mode)
+int file;
+char * mode;
+{
+ return __fopen((char*)0, file, (FILE*)0, mode);
+}
+#endif
+
+#ifdef L___fopen
/*
- * This Fopen is all three of fopen, fdopen and freopen. The macros in
- * stdio.h show the other names.
+ * This is the common code for all three of fopen, fdopen and freopen.
*/
FILE *
__fopen(fname, fd, fp, mode)
diff --git a/libc/stdio/stdio.h b/libc/stdio/stdio.h
index fd10923..cbdacc3 100644
--- a/libc/stdio/stdio.h
+++ b/libc/stdio/stdio.h
@@ -111,11 +111,14 @@ extern int fputc __P((int, FILE*));
extern int fclose __P((FILE*));
extern int fflush __P((FILE*));
extern char *fgets __P((char*, size_t, FILE*));
-extern FILE *__fopen __P((char*, int, FILE*, char*));
-#define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode))
-#define freopen(__file, __mode, __fp) __fopen((__file), -1, (__fp), (__mode))
-#define fdopen(__file, __mode) __fopen((char*)0, (__file), (FILE*)0, (__mode))
+extern FILE *fopen __P((char*, char*));
+extern FILE *fdopen __P((int, char*));
+extern FILE *freopen __P((char*, char*, FILE*));
+
+#ifdef __LIBC__
+extern FILE *__fopen __P((char*, int, FILE*, char*));
+#endif
extern int fputs __P((char*, FILE*));
extern int puts __P((char*));
diff --git a/libc/syscall/syscall.dev86 b/libc/syscall/syscall.dev86
index 2c5384c..d572487 100644
--- a/libc/syscall/syscall.dev86
+++ b/libc/syscall/syscall.dev86
@@ -4,17 +4,15 @@
# ELKSemu and elks itself. Changes to this may require changes in
# all three of those packages.
#
-# . = Ok, with comment
-# * = Needs libc code (Prefix __)
-# - = Obsolete/not required
-# @ = May be required later
+# '.' = Ok, with comment
+# '*' = Needs libc code (Prefix __)
+# '-' = Obsolete/not required
+# '@' = May be required later
+# '=' = Depends on stated config variable
#
# An initial plus on the call number specifies that this call is
# implemented in the kernel.
#
-# Package versions are matched.
-# Dev86/Elksemu version - 0.13.1
-# Elks version - 0.0.66
#
# Name No Args Flag, comment
#
@@ -69,7 +67,7 @@ signal +48 2 * have put the despatch table in user space.
getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc
fcntl +50 3
acct 51 1 @ Accounting to named file (off if null)
-phys 52 3 - Replaced my mmap()
+phys 52 3 - Replaced by mmap()
lock 53 1 @ Prevent swapping for this proc if flg!=0
ioctl +54 3 . make this and fcntl the same ?
reboot +55 3 . the magic number is 0xfee1,0xdead,...
@@ -82,7 +80,7 @@ settimeofday +61 2
gettimeofday +62 2
select +63 5 . 5 paramaters is possible
readdir +64 3 *
-insmod +65 1
+insmod 65 1 - Removed support for modules
fchown +66 3
dlload +67 2
setsid +68 0
@@ -91,6 +89,7 @@ bind +70 3
listen +71 2
accept +72 3
connect +73 3
+knlvsn +74 1 = CONFIG_SYS_VERSION
#
# Name No Args Flag&comment
#
diff --git a/makefile.in b/makefile.in
index 5089564..d921d74 100644
--- a/makefile.in
+++ b/makefile.in
@@ -32,15 +32,15 @@ AR=ar86
#ifdef __GNUC__
# unproto is yukky, I've included '-w' in the local makefile.
-WALL =-Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \
+WALL =-Wall -Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \
-Wcast-qual -Wcast-align -Wconversion -Waggregate-return \
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls \
-Wnested-externs -Winline
-WALL =-Wstrict-prototypes
+WALL =-Wall -Wstrict-prototypes
-CC =gcc
-CFLAGS =$(GCCFLAG) -Wall $(WALL) -O2 -g
+CC =%CC%
+CFLAGS =$(GCCFLAG) $(WALL) -O2 -g
#endif
#ifndef GNUMAKE
diff --git a/man/bcc.1 b/man/bcc.1
index fb88ac8..ed7ccd0 100644
--- a/man/bcc.1
+++ b/man/bcc.1
@@ -71,7 +71,7 @@ preprocessor define
produce preprocessor output to standard out.
.TP
.B -G
-produce GCC objects (only useful for i386 code)
+produce GCC objects (Same as -Mg)
.TP
.B -Ixyz
include search 'xyz' path
@@ -116,6 +116,11 @@ This configuration accepts the
.B -z
flag to generate QMAGIC a.out files instead of the normal OMAGIC.
.TP
+.B -Mg
+switches to i386-Linux code generator and generates OMAGIC object files
+that can be linked with some versions of gcc; unfortunatly the most recent
+versions use 'collect2' to link and this crashes.
+.TP
.B -N
makes the linker produce a native a.out file (Linux OMAGIC) if combined
with -3 the executable will run under Linux-i386.
diff --git a/tests/Makefile b/tests/Makefile
index f2dc16b..015f65e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -6,10 +6,10 @@ BCC=bcc
CC=$(BCC)
CFLAGS=-O
-SRC=env.c ft.c hd.c size.c sync.c compr.c ucomp.c ouch.c lines.c \
+SRC=env.c ft.c hd.c sync.c compr.c ucomp.c ouch.c lines.c \
wc.c line2.c rand.c grab.c
OBJ=
-EXE=env ft hd size sync compr ucomp ouch lines wc line2 rand grab
+EXE=env ft hd sync compr ucomp ouch lines wc line2 rand grab
LINK_FILES=cat chgrp chmod chown cp install ln mkdir mkfifo mknod mv rm
diff --git a/tests/a.out b/tests/a.out
new file mode 100755
index 0000000..14156c6
--- /dev/null
+++ b/tests/a.out
Binary files differ
diff --git a/tests/ft.c b/tests/ft.c
index 027b4c5..c27c5dd 100644
--- a/tests/ft.c
+++ b/tests/ft.c
@@ -42,7 +42,7 @@
#define PR(x) ()
#endif
-void main PR((int argc, char ** argv));
+int main PR((int argc, char ** argv));
int select_command PR((char * argv));
void do_prep PR((void));
void do_post PR((void));
@@ -156,7 +156,7 @@ struct stat access_stat;
int done_something = 0;
-void
+int
main(argc, argv)
int argc; char ** argv;
{
@@ -261,7 +261,7 @@ int argc; char ** argv;
else
Usage();
}
- exit(0);
+ return 0;
}
int select_command(argv)
diff --git a/tests/hd.c b/tests/hd.c
index 3df7761..2be4425 100644
--- a/tests/hd.c
+++ b/tests/hd.c
@@ -1,7 +1,27 @@
+/*
+ * This is a Xenix style hex dump command.
+ *
+ * The 'reverse hex dump' option is an addition that allows a simple
+ * method of editing binary files.
+ *
+ * The overkill Linux 'hexdump' command can be configured to generate
+ * the same format as this command by this shell macro:
+ *
+ * hd() { hexdump -e '"%06.6_ax:" 8/1 " %02x" " " 8/1 " %02x" " " ' \
+ * -e '16/1 "%_p" "\n"' \
+ * "$@"
+ * }
+ *
+ */
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
+#ifndef MSDOS
+#ifndef __BCC__
+#include <locale.h>
+#endif
+#endif
int lastnum[16] = {-1};
long lastaddr = -1;
@@ -9,7 +29,7 @@ long offset = 0;
FILE *fd;
-FILE * ofd = stdout;
+FILE * ofd;
char * outfile = 0;
int reverse = 0;
@@ -21,6 +41,14 @@ char **argv;
int ar;
int aflag = 1;
+#ifndef MSDOS
+#ifndef __BCC__
+ setlocale(LC_CTYPE, "");
+#endif
+#endif
+
+ ofd = stdout;
+
for (ar = 1; ar < argc; ar++)
if (aflag && argv[ar][0] == '-')
switch (argv[ar][1])
@@ -119,7 +147,7 @@ do_fd()
break;
num[j] = ch;
- if (isascii(ch) && isprint(ch))
+ if (isprint(ch))
buf[j] = ch;
else
buf[j] = '.';
@@ -195,8 +223,12 @@ do_rev_fd()
ptr = str;
if( *ptr == '*' ) zap_last = 0;
- if( !isxdigit(*ptr) ) continue;
- addr = strtol(ptr, &ptr, 16);
+ if( *ptr != ':' ) {
+ if( !isxdigit(*ptr) ) continue;
+ addr = strtol(ptr, &ptr, 16);
+ }
+ else
+ addr = nxtaddr;
if( *ptr == ':' ) ptr++;
if (nxtaddr == 0)
diff --git a/tests/size.c b/tests/size.c
deleted file mode 100644
index 6b08f46..0000000
--- a/tests/size.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <fcntl.h>
-#include <a.out.h>
-
-int verbose = 0;
-
-void size(filename)
- char *filename;
-{
- int f;
- struct exec ex;
- long total;
- int cc;
-
- if ((f = open(filename, O_RDONLY)) < 0 )
- {
- perror(filename);
- return;
- }
- cc = read(f, &ex, sizeof(ex));
-
- if (cc == sizeof(ex) && !BADMAG(ex))
- {
- total = ex.a_text + ex.a_data + ex.a_bss;
- if( verbose )
- {
- printf("Text segment of %s = %5ld (0x%lx)\n",
- filename, ex.a_text, ex.a_text);
- printf("Init data of %s = %5ld (0x%lx)\n",
- filename, ex.a_data, ex.a_data);
- printf("Uninit data of %s = %5ld (0x%lx)\n",
- filename, ex.a_bss, ex.a_bss);
- printf("Data segment of %s = %5ld (0x%lx)\n",
- filename, ex.a_total, ex.a_total);
- printf("Minimum size of %s = %5ld (0x%lx)\n",
- filename, total, total);
-
- total = ex.a_total;
- if( ex.a_flags & A_SEP )
- total += ex.a_text;
- printf("Maximum size of %s = %5ld (0x%lx)\n",
- filename, total, total);
- }
- else
- printf("%-ld\t%-ld\t%-ld\t%-ld\t%-lx\t%s\n",
- ex.a_text, ex.a_data, ex.a_bss, total, total,
- filename);
- }
- else if( cc > 16 && memcmp(&ex, "\243\206\001\000*", 5) == 0 )
- { /* *.o file */
- total = ((unsigned char*)&ex)[9] +
- ((unsigned char*)&ex)[10] * 256;
- if( verbose )
- printf("Size of object %s = %5ld (0x%lx)\n",
- filename, total, total);
- else
- printf("\t\t\t%-ld\t%-lx\t%s\n",
- total, total, filename);
- }
- else
- printf("%s: Not an a.out file\n", filename);
- close(f);
-}
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
- if (argc > 1 && strcmp(argv[1], "-v") == 0 )
- {
- verbose++;
- argc--, argv++;
- }
- if (argc < 2)
- {
- printf("Usage: %s [-v] file\n", argv[0]);
- exit(1);
- }
- if(!verbose)
- printf("text\tdata\tbss\tdec\thex\tfilename\n");
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- size(*argv);
- exit(0);
-}
diff --git a/unproto/Makefile b/unproto/Makefile
index a9a8c04..5381719 100644
--- a/unproto/Makefile
+++ b/unproto/Makefile
@@ -38,7 +38,7 @@ SKIP =
# 7. Specify a string constant with exactly three octal digits. If you
# change this definition, you will have to update the example.out file.
#
-BELL = -DBELL=\"007\"
+# BELL = -DBELL=\"007\"
# Some C compilers have problems with "void". The nature of the problems
# depends on the age of the compiler.
diff --git a/unproto/unproto.c b/unproto/unproto.c
index 945e066..9dcdf1a 100644
--- a/unproto/unproto.c
+++ b/unproto/unproto.c
@@ -220,6 +220,9 @@ char **argv;
cpp_pid = pipe_stdin_through_cpp(argv);
#endif
#ifdef REOPEN
+#ifdef PIPE_THROUGH_CPP
+#error Defines REOPEN and PIPE_THROUGH_CPP are incompatible.
+#endif
if ( argc > 1 ) {
if( freopen(argv[1], "r", stdin) == 0 ) {
fprintf(stderr, "Cannot open '%s'\n", argv[1]);