/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/dump.c,v 9.30 1989/11/30 03:03:51 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/dump.c,v 9.31 1990/10/05 18:58:04 jinx Exp $
Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
extern long compiler_interface_version, compiler_processor_type;
void
-prepare_dump_header(Buffer, Dumped_Object,
- Heap_Count, Heap_Relocation,
- Constant_Count, Constant_Relocation,
- table_length, table_size,
- cc_code_p, band_p)
+prepare_dump_header (Buffer, Dumped_Object,
+ Heap_Count, Heap_Relocation,
+ Constant_Count, Constant_Relocation,
+ table_length, table_size,
+ cc_code_p, band_p)
SCHEME_OBJECT
*Buffer, *Dumped_Object,
*Heap_Relocation, *Constant_Relocation;
}
\f
Boolean
-Write_File(Dumped_Object, Heap_Count, Heap_Relocation,
- Constant_Count, Constant_Relocation,
- table_start, table_length, table_size,
- cc_code_p, band_p)
+Write_File (Dumped_Object, Heap_Count, Heap_Relocation,
+ Constant_Count, Constant_Relocation,
+ table_start, table_length, table_size,
+ cc_code_p, band_p)
SCHEME_OBJECT
*Dumped_Object,
*Heap_Relocation, *Constant_Relocation,
Boolean cc_code_p, band_p;
{
SCHEME_OBJECT Buffer[FASL_HEADER_LENGTH];
-
- prepare_dump_header(Buffer, Dumped_Object,
- Heap_Count, Heap_Relocation,
- Constant_Count, Constant_Relocation,
- table_length, table_size, cc_code_p, band_p);
- if (Write_Data(FASL_HEADER_LENGTH, ((char *) Buffer)) !=
+ unsigned long checksum, checksum_area ();
+
+ prepare_dump_header (Buffer, Dumped_Object,
+ Heap_Count, Heap_Relocation,
+ Constant_Count, Constant_Relocation,
+ table_length, table_size, cc_code_p, band_p);
+
+ /* This is not done in prepare_dump_header because it doesn't
+ work when prepare_dump_header is invoked from bchdmp.
+ The areas don't really have these values.
+ For the time being, bchdmp does not dump checksums.
+ */
+
+ checksum = (checksum_area (((unsigned long *) (&Buffer[0])),
+ ((long) FASL_Offset_Check_Sum),
+ ((unsigned long) 0L)));
+ checksum = (checksum_area (((unsigned long *)
+ (&Buffer[FASL_Offset_Check_Sum + 1])),
+ ((long) ((FASL_HEADER_LENGTH - 1) -
+ FASL_Offset_Check_Sum)),
+ checksum));
+ checksum = (checksum_area (((unsigned long *) Heap_Relocation),
+ Heap_Count,
+ checksum));
+ checksum = (checksum_area (((unsigned long *) Constant_Relocation),
+ Constant_Count,
+ checksum));
+ checksum = (checksum_area (((unsigned long *) table_start),
+ table_size,
+ checksum));
+ Buffer[FASL_Offset_Check_Sum] = checksum;
+
+ if (Write_Data (FASL_HEADER_LENGTH, ((char *) Buffer)) !=
FASL_HEADER_LENGTH)
{
return (false);
}
return (true);
}
+\f
+extern unsigned long checksum_area ();
+
+unsigned long
+checksum_area (start, count, initial_value)
+ register unsigned long *start;
+ register long count;
+ unsigned long initial_value;
+{
+ register unsigned long value;
+
+ value = initial_value;
+ while ((--count) >= 0)
+ {
+ value = (value ^ (*start++));
+ }
+ return (value);
+}
+
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/fasload.c,v 9.56 1990/08/16 23:36:51 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/fasload.c,v 9.57 1990/10/05 18:58:30 jinx Exp $
Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology
DEFUN_VOID (read_file_end)
{
SCHEME_OBJECT *table;
+ extern unsigned long checksum_area ();
if ((Load_Data(Heap_Count, ((char *) Free))) != Heap_Count)
{
OS_channel_close_noerror (load_channel);
signal_error_from_primitive (ERR_IO_ERROR);
}
+ computed_checksum =
+ (checksum_area (((unsigned long *) Free),
+ Heap_Count,
+ computed_checksum));
NORMALIZE_REGION(((char *) Free), Heap_Count);
Free += Heap_Count;
OS_channel_close_noerror (load_channel);
signal_error_from_primitive (ERR_IO_ERROR);
}
+ computed_checksum =
+ (checksum_area (((unsigned long *) Free_Constant),
+ Const_Count,
+ computed_checksum));
NORMALIZE_REGION(((char *) Free_Constant), Const_Count);
Free_Constant += Const_Count;
OS_channel_close_noerror (load_channel);
signal_error_from_primitive (ERR_IO_ERROR);
}
+ computed_checksum =
+ (checksum_area (((unsigned long *) Free),
+ Primitive_Table_Size,
+ computed_checksum));
NORMALIZE_REGION(((char *) table), Primitive_Table_Size);
Free += Primitive_Table_Size;
OS_channel_close_noerror (load_channel);
+
+ if ((computed_checksum != ((unsigned long) 0)) &&
+ (dumped_checksum != SHARP_F))
+ {
+ signal_error_from_primitive (ERR_IO_ERROR);
+ }
return (table);
}
\f
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/load.c,v 9.28 1989/09/20 23:09:52 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/load.c,v 9.29 1990/10/05 18:58:18 jinx Exp $
Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
Primitive_Table_Size, Primitive_Table_Length,
dumped_processor_type, dumped_interface_version;
+static unsigned long
+ dumped_checksum, computed_checksum;
+
static SCHEME_OBJECT
Ext_Prim_Vector,
dumped_utilities;
\f
void
-print_fasl_information()
+print_fasl_information ()
{
- printf("FASL File Information:\n\n");
- printf("Machine = %ld; Version = %ld; Subversion = %ld\n",
- Machine_Type, Version, Sub_Version);
+ printf ("FASL File Information:\n\n");
+ printf ("Machine = %ld; Version = %ld; Subversion = %ld\n",
+ Machine_Type, Version, Sub_Version);
if ((dumped_processor_type != 0) || (dumped_interface_version != 0))
{
- printf("Compiled code interface version = %ld; Processor type = %ld\n",
- dumped_interface_version, dumped_processor_type);
+ printf ("Compiled code interface version = %ld; Processor type = %ld\n",
+ dumped_interface_version, dumped_processor_type);
}
if (band_p)
{
- printf("The file contains a dumped image (band).\n");
+ printf ("The file contains a dumped image (band).\n");
}
- printf("\nRelocation Information:\n\n");
- printf("Heap Count = %ld; Heap Base = 0x%lx; Heap Top = 0x%lx\n",
- Heap_Count, Heap_Base, Dumped_Heap_Top);
- printf("Const Count = %ld; Const Base = 0x%lx; Const Top = 0x%lx\n",
- Const_Count, Const_Base, Dumped_Constant_Top);
- printf("Stack Top = 0x%lx\n", Dumped_Stack_Top);
+ printf ("\nRelocation Information:\n\n");
+ printf ("Heap Count = %ld; Heap Base = 0x%lx; Heap Top = 0x%lx\n",
+ Heap_Count, Heap_Base, Dumped_Heap_Top);
+ printf ("Const Count = %ld; Const Base = 0x%lx; Const Top = 0x%lx\n",
+ Const_Count, Const_Base, Dumped_Constant_Top);
+ printf ("Stack Top = 0x%lx\n", Dumped_Stack_Top);
- printf("\nDumped Objects:\n\n");
- printf("Dumped object at 0x%lx (as read from file)\n", Dumped_Object);
- printf("Compiled code utilities vector = 0x%lx\n", dumped_utilities);
+ printf ("\nDumped Objects:\n\n");
+ printf ("Dumped object at 0x%lx (as read from file)\n", Dumped_Object);
+ printf ("Compiled code utilities vector = 0x%lx\n", dumped_utilities);
if (Ext_Prim_Vector != SHARP_F)
{
- printf("External primitives vector = 0x%lx\n", Ext_Prim_Vector);
+ printf ("External primitives vector = 0x%lx\n", Ext_Prim_Vector);
}
else
{
- printf("Length of primitive table = %ld\n", Primitive_Table_Length);
+ printf ("Length of primitive table = %ld\n", Primitive_Table_Length);
}
+ printf ("Checksum = 0x%lx\n", dumped_checksum);
return;
}
\f
long
-Read_Header()
+Read_Header ()
{
SCHEME_OBJECT Buffer[FASL_HEADER_LENGTH];
SCHEME_OBJECT Pointer_Heap_Base, Pointer_Const_Base;
- if (Load_Data(FASL_HEADER_LENGTH, ((char *) Buffer)) !=
+ if (Load_Data (FASL_HEADER_LENGTH, ((char *) Buffer)) !=
FASL_HEADER_LENGTH)
{
return (FASL_FILE_TOO_SHORT);
{
return (FASL_FILE_NOT_FASL);
}
- NORMALIZE_HEADER(Buffer,
- (sizeof(Buffer) / sizeof(SCHEME_OBJECT)),
- Buffer[FASL_Offset_Heap_Base],
- Buffer[FASL_Offset_Heap_Count]);
+ NORMALIZE_HEADER (Buffer,
+ (sizeof(Buffer) / sizeof(SCHEME_OBJECT)),
+ Buffer[FASL_Offset_Heap_Base],
+ Buffer[FASL_Offset_Heap_Count]);
Heap_Count = OBJECT_DATUM (Buffer[FASL_Offset_Heap_Count]);
Pointer_Heap_Base = Buffer[FASL_Offset_Heap_Base];
Heap_Base = OBJECT_DATUM (Pointer_Heap_Base);
}
\f
#ifndef INHIBIT_FASL_VERSION_CHECK
-
/* The error messages here should be handled by the runtime system! */
if ((Version != FASL_READ_VERSION) ||
((dumped_interface_version != 0) &&
(dumped_interface_version != compiler_interface_version)))
{
- fprintf(stderr, "\nread_file:\n");
- fprintf(stderr,
- "FASL File: compiled code interface %4d; processor %4d.\n",
- dumped_interface_version, dumped_processor_type);
- fprintf(stderr,
- "Expected: compiled code interface %4d; processor %4d.\n",
- compiler_interface_version, compiler_processor_type);
+ fprintf (stderr, "\nread_file:\n");
+ fprintf (stderr,
+ "FASL File: compiled code interface %4d; processor %4d.\n",
+ dumped_interface_version, dumped_processor_type);
+ fprintf (stderr,
+ "Expected: compiled code interface %4d; processor %4d.\n",
+ compiler_interface_version, compiler_processor_type);
return (((dumped_processor_type != 0) &&
(dumped_processor_type != compiler_processor_type)) ?
FASL_FILE_BAD_PROCESSOR :
#endif /* INHIBIT_COMPILED_VERSION_CHECK */
+ dumped_checksum = (Buffer [FASL_Offset_Check_Sum]);
+
+#ifndef INHIBIT_CHECKSUMS
+
+ {
+ extern unsigned long checksum_area ();
+
+ computed_checksum =
+ (checksum_area (((unsigned long *) &Buffer[0]),
+ ((unsigned long) (FASL_HEADER_LENGTH)),
+ ((unsigned long) 0)));
+
+ }
+
+#endif /* INHIBIT_CHECKSUMS */
+
return (FASL_FILE_FINE);
}
\f