;:ts=8
	far	code
	far	data
;//  Version 2.20 changes:
;//		Fixed sci_logger_value_to_voltage() to properly account for the front-end
;//		gain when executing the "read science <channel>" command.  8/1/98
;
;//  TT8 specific includes
;#include        <TT8.h>                 /* Tattletale Model 8 Definitions */
;#include        <tat332.h>              /* 68332 Tattletale (7,8) Hardware Definitions */
;#include        <sim332.h>              /* 68332 System Integration Module Definitions */
;#include        <qsm332.h>              /* 68332 Queued Serial Module Definitions */
;#include        <tpu332.h>              /* 68332 Time Processing Unit Definitions */
;#include        <dio332.h>              /* 68332 Digital I/O Port Pin Definitions */
;#include        <tt8pic.h>              /* Model 8 PIC Parallel Slave Port Definitions */
;#include        <tt8lib.h>              /* definitions and prototypes for Model 8 library */
;
;//  general C includes
;#include        <stdio.h>
;#include        <stdlib.h>
;
;//  includes for the data logger
;#include                "assert.h"
;#include                "ad7716.h"
;#include				"max186.h"
;#include                "science.h"
;#include                "eeprom.h"
;#include                "engineer.h"
;#include                "logtime.h"
	dseg
	ds	0
_LATEST_LOGGER_TIME:
	ds.b	0
	dc.l	$ffffffff
	dc.l	$0000
	cseg
	dseg
	ds	0
_EARLIEST_LOGGER_TIME:
	ds.b	0
	dc.l	$0000
	dc.l	$0000
	cseg
;#include                "logdisk.h"
;#include                "commands.h"
;#include                "logger.h"
;#include                "text_log.h"
;#include                "intexcpt.h"
;#include                "lpsleep.h"
;#include				"logdisk.h"
;#include				"criterr.h"
;
;
;//  includes for the disk routines
;#include                <pcdisk.h>
;
;//  'previous command' char is backspace
;const uchar PREVIOUS_COMMAND = 0x08;
	ds	0
	xdef	_PREVIOUS_COMMAND
_PREVIOUS_COMMAND:
	dc.b	8
	cseg
;const float SOFTWARE_VERSION = 2.48;
	ds	0
	xdef	_SOFTWARE_VERSION
_SOFTWARE_VERSION:
	dc.b	$40,$1e,$b8,$52
	cseg
;
;
;//  The next few lines define the allowed clock frequency for various
;//  functions, including the nominal TT8 clock, the disk access frequency
;//  (too slow -> wasting power, too fast -> hardware errors), the min
;//  speed to execute a sync time set or read, and the min speed to
;//  read the engineering channels (which must pause interrupt servicing
;//  of the science channels, since they share the SPI interface).
;#ifdef DEBUG
;	long TT8_clock_freq = (long)16e6;
;#else
;	#ifdef SIMULATE_DATA
;		//  Run all out when simulating data
;		long TT8_clock_freq = (long)(16e6);
;	#else
;		//  fast enough for conversion rate of 128 Hz when not computing triggering
;		long TT8_clock_freq = (long)(2.56e6);
	dseg
	ds	0
	xdef	_TT8_clock_freq
_TT8_clock_freq:
	dc.l	$271000
	cseg
;	#endif	
;#endif
;const long DISK_FREQ = (long)8e6;
	ds	0
	xdef	_DISK_FREQ
_DISK_FREQ:
	dc.l	$7a1200
	cseg
;const long MIN_TIME_SET_FREQ = (long)8e6;
	ds	0
	xdef	_MIN_TIME_SET_FREQ
_MIN_TIME_SET_FREQ:
	dc.l	$7a1200
	cseg
;const long MIN_ENG_READ_FREQ = (long)8e6;
	ds	0
	xdef	_MIN_ENG_READ_FREQ
_MIN_ENG_READ_FREQ:
	dc.l	$7a1200
	cseg
;
;//  Structure to group together the data used by the top level supervisor
;//  routine which starts all of the sub-systems.
;struct supervisor  {
;	uchar COM_buffer[128];      //  buffer for input strings which user types
;	short n_in_COM_buffer;      //  number of chars in the COM buffer
;	short disks_full;
;} supervisor;
;
;
;//  local subroutines used only within this module
;short collect_COM_input (void);
;short process_COM_input (void);
;void collect_data (void);
;int disk_access (void);
;void print_CRC (void);
;char* get_stkbase (void);
;#ifdef DEBUG
;	void debug_init (void);
;	void debug_end (void);
;#endif  
;
;
;
;void main (void)  {
# 89 'main.c' 679115201
| .2
	xdef	_main
_main:
	link	a6,#.3
;	long delay;
;	time_tt now;
;
;	//  setup Model 8 for running C programs
;	InitTT8(NO_WATCHDOG, TT8_TPU);
~ ''
~ 1 2 8
~ secs 0 "L"
~ ticks 4 "l"
~ now -8 ":" 1
^^^^^	move.w	#-1,-(sp)
	move.w	#-1,-(sp)
	jsr	_InitTT8
;	printf ("\nStarted...\n");
^	pea	.1+0
	jsr	_printf
;
;	//  Init pins so as to avoid unconnected inputs, which can draw an
;	//  inordinant amount of power.  This routine should be called only
;	//  early in the execution sequence, as some of its settings will
;	//  be overwridden by the more advanced functions of the logger.
;	prep_pins_low_power ();
^^^^^^	jsr	_prep_pins_low_power
;
;	//  switch to normal speed and baud.  This is the only place that we
;	//  need to set the default frequency.  Every other routine which changes
;	//  the frequency first saves the original frequency and then sets it
;	//  back when it is done
;	SimSetFSys(TT8_clock_freq);
^^^^^^	move.l	_TT8_clock_freq,-(sp)
	jsr	_SimSetFSys
;	SerSetBaud(9600L,0L);
^	clr.l	-(sp)
	pea	9600
	jsr	_SerSetBaud
;	printf ("\n\nGEOSense data logger.  This is software version %.2f.\n", SOFTWARE_VERSION);
^	move.l	_SOFTWARE_VERSION,d0
	jsr	.ftod#
	move.l	d1,-(sp)
	move.l	d0,-(sp)
	pea	.1+13
	jsr	_printf
;
;	//  Init all of the sub-systems.  Be sure to init the text logging routines
;	//  and the time routines first since the other routines may call them
;	log_power_on_init ();
^^^^	jsr	_log_power_on_init
;	logger_time_power_on_init ();
^	jsr	_logger_time_power_on_init
;
;	//  check and log the CRC for the TOM8 monitor
;	print_CRC ();
^^^	jsr	_print_CRC
;
;	//  log the startup now that the basic inits are done
;	log_printf ("\n\nGEOSense data logger.  This is software version %.2f.\n", SOFTWARE_VERSION);
^^^	move.l	_SOFTWARE_VERSION,d0
	jsr	.ftod#
	move.l	d1,-(sp)
	move.l	d0,-(sp)
	pea	.1+70
	jsr	_log_printf
;	now = ttmnow ();
^	lea	-8(a6),a0
	lea	44(sp),sp
	move.l	a0,-(sp)
	jsr	_ttmnow
	move.l	d0,a0
	move.l	(sp)+,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
;	log_printf ("The current time is %s", logger_time_get_string (&now));
^	pea	-8(a6)
	jsr	_logger_time_get_string
	add.w	#4,sp
	move.l	d0,-(sp)
	pea	.1+127
	jsr	_log_printf
;
;	#ifdef DEBUG
;	printf ("\n*****************************************************************\n");
;	printf ("The data logger software is currently running in debug mode.\n");
;	printf ("Lots of error checking code requires a fast clock speed and has\n");
;	printf ("increased power consumption beyond the norm.  We do not recommend\n");
;	printf ("deployment of this code.\n");
;	printf ("*****************************************************************\n");
;	#endif
;	#ifdef SIMULATE_DATA
;	printf ("\n*****************************************************************\n");
;	printf ("The data logger software is currently running in SIMULATE DATA mode.\n");
;	printf ("None of the recorded data is real.\n");
;	printf ("DO NOT DEPLOY THIS CODE!\n");
;	printf ("*****************************************************************\n");
;	#endif
;	
;
;	//  If the stack is high up in memory, then this must be the 256k version
;	//  The stack for the 1 Meg version should be at 0x200000
;	if (get_stkbase() == (char*)0x2C0000)  {
^^^^^^^^^^^^^^^^^^^^
^	jsr	_get_stkbase
	cmp.l	#2883584,d0
	add.w	#8,sp
	bne	.10001
;		#ifndef DEBUG
;		printf ("\n***********************************************************\n");
^^	pea	.1+150
	jsr	_printf
;		#endif
;		printf ("This code was compiled for a TT8 with 256 kbytes of memory.\n");
^^	pea	.1+212
	jsr	_printf
;		printf ("It will only use 256 kbytes of memory, even if run on a TT8\n");
^	pea	.1+273
	jsr	_printf
;		printf ("with 1 Mbyte.  Recompile for proper operation on a 1 M TT8.\n");
^	pea	.1+334
	jsr	_printf
;		printf ("***********************************************************\n");
^	pea	.1+395
	jsr	_printf
;	}       
^;
;	#ifdef DEBUG
;	//  inits which apply only to the debug version of this program
;	debug_init ();                                  
;	#endif                                                                  
;	init_IDE ();                    //  inits for the IDE disk access
	lea	20(sp),sp
.10001
^^^^^^	jsr	_init_IDE
;	AD7716_power_on_init ();        //  init of the interface to the AD7716 A/D
^	jsr	_AD7716_power_on_init
;	MAX186_power_on_init ();
^	jsr	_MAX186_power_on_init
;	logger_disk_power_on_init ();   //  verifies availability of disk drives
^	jsr	_logger_disk_power_on_init
;	sci_logger_power_on_init ();    //  and the science logger
^	jsr	_sci_logger_power_on_init
;	eng_logger_power_on_init ();    //  and the engineering logger
^	jsr	_eng_logger_power_on_init
;	eeprom_read_setup_data (0);     //  reads the logger setup data from the eeprom
^	clr.w	-(sp)
	jsr	_eeprom_read_setup_data
;
;	//  REVIEW
;	//  A bit of a kluge, but sometimes useful.  This allows us to remember the
;	//  tick offsets as set by a sync set command through a complete code reset
;	//  This is useful if our code resets itself, or if the user quits and restarts
;	//  the program.  It is not useful if power has been cycled.
;	if (logger_time_verify_set () == 0)
^^^^^^^;		logger_time_set_tick_offset (setup_data.tick_offset);
	jsr	_logger_time_verify_set
	tst.w	d0
	add.w	#2,sp
	bne	.10002
^	move.l	_setup_data+78,-(sp)
	jsr	_logger_time_set_tick_offset
;		
;//      disk_power_on_init ();      //  not yet implemented; only important for
;									//  multi-disk systems
;	
;	//  sets up routines to catch unexpected interrupts or exceptions
;	unexpected_int_init ();
	add.w	#4,sp
.10002
^^^^^^	jsr	_unexpected_int_init
;	
;	//  REVIEW - we would like a better way of tracking disk errors so that we
;	//  can avoid pointless and power hungry retries while still allowing
;	//  a reasonable recovery from errors.
;	//  This will be set non-zero if we get a disk error
;	supervisor.disks_full = 0;
^^^^^^	clr.w	_supervisor+130
;	
;	supervisor.n_in_COM_buffer = 0;
^^	clr.w	_supervisor+128
;	supervisor.COM_buffer[0] = '\0';
^	clr.b	_supervisor
;
;	//  The logger starts out suspended for 10 minutes.  It will start
;	//  automatically at the end of this time.
;	logger_suspend (600L);
^^^^	pea	600
	jsr	_logger_suspend
;	
;	//  processing a command with no data present will force a print
;	//  of the command prompt.
;	process_COM_input ();
^^^^	jsr	_process_COM_input
;
;	//  This is the main data logger loop
;	for (;;)  {
^^^	add.w	#4,sp
.10005
;		//  Check to see if the logger is suspended and if it needs restarting
;        if (logger_get_seconds_to_start () != 0)  {
^^	jsr	_logger_get_seconds_to_start
	tst.l	d0
	beq	.10006
;			//  don't restart the logger if there are no disks available!
;			if (supervisor.disks_full == 0)
^^;				logger_verify_suspension ();
	tst.w	_supervisor+130
	bne	.10007
^	jsr	_logger_verify_suspension
;		}
.10007
^;
;		//  After any operation which may take a long time, such as a command
;		//  or a disk access,  we check to see if the input buffer for the
;		//  science logger overflowed.
;		if (collect_COM_input () != 0)  {
.10006
^^^^^	jsr	_collect_COM_input
	tst.w	d0
	beq	.10008
;			if (process_COM_input () != 0)
^;				break;
	jsr	_process_COM_input
	tst.w	d0
	bne	.10004
;			collect_data ();
^^	jsr	_collect_data
;			sci_logger_overflow_check ();
^	jsr	_sci_logger_overflow_check
;		}
^;				
;		//  Check to see if a disk access is required, and dump data to disk
;		//  if necessary
;		if (disk_access ())  {
.10008
^^^^	jsr	_disk_access
	tst.w	d0
	beq	.10009
;			//  If we actually spun the disk, then we need to collect some data
;			//  to be sure we have space in the buffer and then we have to check
;			//  to see if we overflowed the buffer due to a slow disk access and
;			//  reset the collection if we did.
;			collect_data ();
^^^^^	jsr	_collect_data
;			sci_logger_overflow_check ();
^	jsr	_sci_logger_overflow_check
;		}
^;		
;		//  Collect data if any is waiting.  This call and others that it makes
;		//  implements the heart of the data logger
;		collect_data ();
.10009
^^^^	jsr	_collect_data
;
;		//  REVIEW - we should turn off the Serial port to minimize power usage,
;		//  but we must be sure that any error messages being printed are complete
;	}
^^^^.10003
	bra	.10005
.10004
;	
;	//  try to shut down gracefully by doing such things as depowering the analog
;	//  sections.
;	logger_shutdown ();
^^^^	jsr	_logger_shutdown
;	prep_pins_low_power ();
^	jsr	_prep_pins_low_power
;	print_CRC ();
^	jsr	_print_CRC
;
;	#ifdef DEBUG
;	debug_end ();
;	#endif                                                                  
;	ResetToMon ();
^^^^^;			ResetToMon
	dc.w	$13fc
	dc.w	$c1
	dc.w	$e0
	dc.w	$0
	dc.w	$4e70
;}
^.4
	unlk	a6
	rts
.2
.3	equ	-8
.1
	dc.b	10,83,116,97,114,116,101,100,46,46,46,10,0,10,10
	dc.b	71,69,79,83,101,110,115,101,32,100,97,116,97,32,108
	dc.b	111,103,103,101,114,46,32,32,84,104,105,115,32,105,115
	dc.b	32,115,111,102,116,119,97,114,101,32,118,101,114,115,105
	dc.b	111,110,32,37,46,50,102,46,10,0,10,10,71,69,79
	dc.b	83,101,110,115,101,32,100,97,116,97,32,108,111,103,103
	dc.b	101,114,46,32,32,84,104,105,115,32,105,115,32,115,111
	dc.b	102,116,119,97,114,101,32,118,101,114,115,105,111,110,32
	dc.b	37,46,50,102,46,10,0,84,104,101,32,99,117,114,114
	dc.b	101,110,116,32,116,105,109,101,32,105,115,32,37,115,0
	dc.b	10,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	10,0,84,104,105,115,32,99,111,100,101,32,119,97,115
	dc.b	32,99,111,109,112,105,108,101,100,32,102,111,114,32,97
	dc.b	32,84,84,56,32,119,105,116,104,32,50,53,54,32,107
	dc.b	98,121,116,101,115,32,111,102,32,109,101,109,111,114,121
	dc.b	46,10,0,73,116,32,119,105,108,108,32,111,110,108,121
	dc.b	32,117,115,101,32,50,53,54,32,107,98,121,116,101,115
	dc.b	32,111,102,32,109,101,109,111,114,121,44,32,101,118,101
	dc.b	110,32,105,102,32,114,117,110,32,111,110,32,97,32,84
	dc.b	84,56,10,0,119,105,116,104,32,49,32,77,98,121,116
	dc.b	101,46,32,32,82,101,99,111,109,112,105,108,101,32,102
	dc.b	111,114,32,112,114,111,112,101,114,32,111,112,101,114,97
	dc.b	116,105,111,110,32,111,110,32,97,32,49,32,77,32,84
	dc.b	84,56,46,10,0,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
	dc.b	42,42,42,42,10,0
	ds	0
;
;
;
;
;
;//  collect_COM_input ()
;//  
;//  Collects any input waiting at the serial COM port and adds it to the
;//  input buffer.  Replaces the newline with a NULL.
;//
;//  Returns: non-zero if there is a complete line in the buffer
;//
;short collect_COM_input (void)  {
# 257
| .6
	xdef	_collect_COM_input
_collect_COM_input:
	movem.l	d2/d3,-(sp)
;	uchar new_char;
;	long temp;
;
;	//  get input from user if available
;	if (!SerByteAvail())  {  
~ new_char d2 "C"
~ temp d3 "l"
^^^^^	jsr	_SerByteAvail
	tst.w	d0
	bne	.10010
;		#ifndef DEBUG
;			//  don't execute shut down in debug mode because it doesn't allow
;			//  spontaneous printing, and we never know when we will print in
;			//  debug mode.  Second observation: the "wait for xmission to complete"
;			//  function doesn't seem to work properly, which is why there are places
;			//  in this code with calls to DelayMilliSecs() after characters are printed
;			SerShutDown (1, 1);
^^^^^^^	move.w	#1,-(sp)
	move.w	#1,-(sp)
	jsr	_SerShutDown
;		#endif	
;		return 0;
^^	move.l	#0,d0
	add.w	#4,sp
.7
	movem.l	(sp)+,d2/d3
	rts
;	}	
^;
;	//  The documentation implies that SerActivate is not necessary.  Skip
;	//  at Onset indicates that it is not necessary for character reception,
;	//  but it is necessary for xmission.  SerActivate powers up the voltage
;	//  converters that are part of the Maxim RS232 chip.  Try allowing 2 mS
;	//  for power up
;	SerActivate ();
.10010
^^^^^^^	jsr	_SerActivate
;    temp = StopWatchTime ();
^	jsr	_StopWatchTime
	move.l	d0,d3
;   	temp += 50000;
^	add.l	#50000,d3
;    while (StopWatchTime () < temp)
^.10011
	jsr	_StopWatchTime
	cmp.l	d3,d0
	bcc	.10012
;		{;}
^	bra	.10011
.10012
;			
;	new_char = SerGetByte ();
^^	jsr	_SerGetByte
	move.b	d0,d2
;
;	//  Stop science data preview as soon as the user hits a key.  Ok
;	//  to call these routines even if preview is not on.
;	if (supervisor.n_in_COM_buffer == 0)  {
^^^^	tst.w	_supervisor+128
	bne	.10013
;		sci_logger_set_binary_preview (-1);
^	move.w	#-1,-(sp)
	jsr	_sci_logger_set_binary_preview
;		sci_logger_set_ASCII_preview (-1);
^	move.w	#-1,-(sp)
	jsr	_sci_logger_set_ASCII_preview
;	}
^;	
;	//  If this character is a carriage return, then this command line is 
;	//  complete.  Terminate the string and return non-zero to request
;	//  processing of the command string.
;	if (new_char == '\r')  {
	add.w	#4,sp
.10013
^^^^^	cmp.b	#13,d2
	bne	.10014
;		printf ("\n");
^	pea	.5+0
	jsr	_printf
;		//  the use user is only tapping the carriage return key and nothing
;		//  else, then don't erase the previously executed command by filling
;		//  in the NULL, cause this would inhibit the "execute previous cmd"
;		//  function
;		if (supervisor.n_in_COM_buffer != 0)
^^^^^;			supervisor.COM_buffer[supervisor.n_in_COM_buffer] = '\0';
	tst.w	_supervisor+128
	add.w	#4,sp
	beq	.10015
^	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	clr.b	(a0,d0.w)
;		return 1;
.10015
^	move.l	#1,d0
	bra	.7
;	}
^;	
;	//  if not a <return> process char as normal
;	if ((new_char == PREVIOUS_COMMAND) && (supervisor.n_in_COM_buffer == 0))  {
.10014
^^^	cmp.b	_PREVIOUS_COMMAND,d2
	bne	.10016
	tst.w	_supervisor+128
	bne	.10016
;		for (supervisor.n_in_COM_buffer = 0;
^;				supervisor.COM_buffer[supervisor.n_in_COM_buffer] != '\0';
	clr.w	_supervisor+128
	bra	.10020
;										supervisor.n_in_COM_buffer++)  {
.10019
^^;			ASSERT (supervisor.n_in_COM_buffer < sizeof (supervisor.COM_buffer));
^;//          putchar(supervisor.COM_buffer[supervisor.n_in_COM_buffer]);
;			printf ("%c", supervisor.COM_buffer[supervisor.n_in_COM_buffer]);
^^	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	move.l	#0,d1
	move.b	(a0,d0.w),d1
	move.w	d1,-(sp)
	pea	.5+2
	jsr	_printf
;		}       
^	add.w	#6,sp
.10017
	add.w	#1,_supervisor+128
.10020
	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	tst.b	(a0,d0.w)
	bne	.10019
.10018
;	}  else  {
^	bra	.10021
.10016
;		if (new_char == CHAR_BACKSPACE)  {
^	cmp.b	#8,d2
	bne	.10022
;			//  if the char was a backspace, then delete one char from our
;			//  input buffer, but don't allow user to backspace more than
;			//  was typed.  Actually overwrite the char to avoid odd behavoir
;			//  if the user backspaces over a line and then asks for the previous
;			//  line to be redisplayed.
;			if (supervisor.n_in_COM_buffer > 0)  {
^^^^^^	tst.w	_supervisor+128
	ble	.10023
;				supervisor.n_in_COM_buffer--;
^	sub.w	#1,_supervisor+128
;				supervisor.COM_buffer[supervisor.n_in_COM_buffer] = '\0';
^	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	clr.b	(a0,d0.w)
;//          	putchar (CHAR_BACKSPACE);
;				printf ("%c", CHAR_BACKSPACE);
^^	move.w	#8,-(sp)
	pea	.5+5
	jsr	_printf
;			}
^;		}  else  {
	add.w	#6,sp
.10023
^	bra	.10024
.10022
;			supervisor.COM_buffer[supervisor.n_in_COM_buffer] = new_char;
^	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	move.b	d2,(a0,d0.w)
;			//  echo the character
;//                      putchar (supervisor.COM_buffer[supervisor.n_in_COM_buffer]);
;			printf ("%c", supervisor.COM_buffer[supervisor.n_in_COM_buffer]);
^^^	move.w	_supervisor+128,d0
	lea	_supervisor,a0
	move.l	#0,d1
	move.b	(a0,d0.w),d1
	move.w	d1,-(sp)
	pea	.5+8
	jsr	_printf
;			//  don't overflow the buffer; leave room for null at end
;			if (supervisor.n_in_COM_buffer < sizeof(supervisor.COM_buffer)-1)
^^;				supervisor.n_in_COM_buffer++;
	cmp.w	#127,_supervisor+128
	add.w	#6,sp
	bcc	.10025
^	add.w	#1,_supervisor+128
;		}               
.10025
^.10024
;	}               
^.10021
;	//  must call flush to force the char to be output from the queue
;	fflush (stdout);                
^^	pea	__iob+22
	jsr	_fflush
;	DelayMilliSecs (1);
^	pea	1
	jsr	_DelayMilliSecs
;	return 0;
^	move.l	#0,d0
	add.w	#8,sp
	bra	.7
;}                       
^.6
.5
	dc.b	10,0,37,99,0,37,99,0,37,99,0
	ds	0
;
;
;
;//  process_COM_input ()
;//
;//  Looks at the data in the global input buffer and interprets it
;//  as a command.  Processes the command.
;//
;//  Returns: 0 => no further action required
;//                       non-zero => quit the program
;//
;short process_COM_input (void)  {
# 356
| .9
	xdef	_process_COM_input
_process_COM_input:
	movem.l	d2,-(sp)
;	short result = NOOP;
;	
;	//  Process the command, but only if there were chars put in the buffer.
;	//  We must check because we don't erase previous commands (so we can
;	//  implement the "echo previous cmd" function), and we don't want to
;	//  execute cmds twice if the user keeps hitting carriage returns.
;	if (supervisor.n_in_COM_buffer > 0)  {
~ result d2 "i"
	move.l	#0,d2
^^^^^^^	tst.w	_supervisor+128
	ble	.10026
;		result = command_parse ((char*)supervisor.COM_buffer);
^	pea	_supervisor
	jsr	_command_parse
	move.w	d0,d2
;		//  The quit command returns the user to the TT8 monitor.  It is
;		//  implemented as a global command so that we have the option of
;		//  adding code which could clean up after the data logger code
;		if (result == CMD_QUIT)
^^^^;			return 1;
	cmp.w	#2,d2
	add.w	#4,sp
	bne	.10027
^	move.l	#1,d0
.10
	movem.l	(sp)+,d2
	rts
;		
;		//  delete the processed command
;		supervisor.n_in_COM_buffer = 0;
.10027
^^^	clr.w	_supervisor+128
;	}
^;	
;	if (result != CMD_READ_BINARY_SCIENCE)  {
.10026
^^	cmp.w	#110,d2
	beq	.10028
;		printf ("Cmd: ");
^	pea	.8+0
	jsr	_printf
;		fflush (stdout);
^	pea	__iob+22
	jsr	_fflush
;		DelayMilliSecs (5);
^	pea	5
	jsr	_DelayMilliSecs
;	}	
^;	return 0;
	lea	12(sp),sp
.10028
^	move.l	#0,d0
	bra	.10
;}
^.9
.8
	dc.b	67,109,100,58,32,0
	ds	0
;
;
;
;
;//  collect_data ()
;//
;//  Makes subroutine calls to the science and engineering loggers to collect
;//  data as necessary.
;//
;void collect_data (void)  {
# 391
| .12
	xdef	_collect_data
_collect_data:
;	static kluge = 0;
	dseg
	ds	0
.13
	dc.w	0
	cseg
;
;	//  Collect science data.  The argument is the maximum number
;	//  of data points to process on this call.  A large number will
;	//  slow the response of the logger to user inputs after the user
;	//  does something which causes a lot of data to accumulate, such
;	//  as a disk print.  In normal operation, the logger should find
;	//  only a few points waiting.
;	sci_logger_collect (20);
~ kluge .13 "i"
^^^^^^^^^	move.w	#20,-(sp)
	jsr	_sci_logger_collect
;	eng_logger_collect ();
^	jsr	_eng_logger_collect
;    //  Something of a kluge.  We want to make sure the RS232 xmitter is
;    //  shut down without having to call the routine too often, so we
;    //  include the shutdown call here for activation every few seconds
;    //  Parmams instruct to wait for xmit to finish before shutdown and
;    //  to autowake on xmit
;//	if (kluge++ > 100)  {
;//		SerShutDown (1, 1);
;//		kluge = 0;
;//	}
;}
^^^^^^^^^^	add.w	#2,sp
.14
	rts
.12
;
;
;
;
;//  void disk_access ()
;//
;//  Checks to see if any of the sub-systems wants the disk turned on, and
;//  if so, powers on the disk and calls all of the sub-system disk writing
;//  routines.
;//
;int disk_access (void)  {
# 422
| .15
	xdef	_disk_access
_disk_access:
	link	a6,#.16
	movem.l	d2/d3/d4/d5/d6,-(sp)
;	short disk_needed;
;	long freq, baud;
;	short freq_change;
;	dword blocks_free, blocks_total;
;	short error;
;	#if defined(DEBUG) || defined(SIMULATE_DATA)
;	time_tt start_time, stop_time;
;	long dT;
;	#endif	
;
;	//  if the disks are full, don't bother
;	if (supervisor.disks_full != 0)
~ disk_needed d3 "i"
~ freq d4 "l"
~ baud d5 "l"
~ freq_change d6 "i"
~ blocks_free -4 "L"
~ blocks_total -8 "L"
~ error d2 "i"
^^^^^^^^^^^^;		return 0;
	tst.w	_supervisor+130
	beq	.10029
^	move.l	#0,d0
.17
	movem.l	(sp)+,d2/d3/d4/d5/d6
	unlk	a6
	rts
;		
;	disk_needed = 0;
.10029
^^	move.l	#0,d3
;	disk_needed += sci_logger_disk_request ();
^	jsr	_sci_logger_disk_request
	add.w	d0,d3
;	disk_needed += eng_logger_disk_request ();
^	jsr	_eng_logger_disk_request
	add.w	d0,d3
;	disk_needed += log_disk_request (NULL);
^	clr.l	-(sp)
	jsr	_log_disk_request
	add.w	d0,d3
;	if (disk_needed == 0)
^;		return 0;
	tst.w	d3
	add.w	#4,sp
	bne	.10030
^	move.l	#0,d0
	bra	.17
;
;	#ifdef DEBUG
;	if (disk_needed)  {
;		printf ("\ndisk_access starting at: ");
;		cmd_print_time (NULL);
;		if (sci_logger_disk_request())
;			printf ("  sci_logger_disk_request positive\n");	
;		if (eng_logger_disk_request ())
;			printf ("  eng_logger_disk_request positive\n");	
;		if (log_disk_request (NULL))
;			printf ("  log_disk_request positive\n");	
;	}
;	#endif
;	#if defined(DEBUG)
;	start_time = logger_time_get_time ();
;	#endif
;	#if defined(SIMULATE_DATA)
;	StopWatchStart ();
;	#endif
;		
;	//  REVIEW
;	//  Can we detect the disruption of the TT8 that occurs when the disk
;	//  is spun up with a crappy power supply?  (or dead batteries?)
;	//  REVIEW
;	//  Recalculate the maximum frequency we can run the clock at during
;	//  a disk access and still meet the timing requirements of the IDE
;	//  interface.  We may be able to up this frequency.
;	freq = SimGetFSys ();
.10030
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^	jsr	_SimGetFSys
	move.l	d0,d4
;	baud = SerGetBaud (0L, 0L);
^	clr.l	-(sp)
	clr.l	-(sp)
	jsr	_SerGetBaud
	move.l	d0,d5
;	if (freq != DISK_FREQ)  {
^	cmp.l	_DISK_FREQ,d4
	add.w	#8,sp
	beq	.10031
;		SimSetFSys (DISK_FREQ);
^	move.l	_DISK_FREQ,-(sp)
	jsr	_SimSetFSys
;		SerSetBaud (baud, 0L);
^	clr.l	-(sp)
	move.l	d5,-(sp)
	jsr	_SerSetBaud
;		freq_change = 1;
^	move.l	#1,d6
;	} else
^	lea	12(sp),sp
	bra	.10032
.10031
;		freq_change = 0;
^	move.l	#0,d6
.10032
;
;	for (;;)  {
^^.10035
;		//  Switch disks if we have less than 1 mega byte of space left.  If we have this
;		//  much left, then we can be certain we will not run out while dumping the data
;		//  to disk.  The downside is that we waste up to 1 MB of space on the disk.  However,
;		//  on a typical 4 GB disk, this is 0.025% of the total, which isn't much.  The
;		//  positive side of doing it this way is that the switch from disk to disk occurs
;		//  only at this point in the code, as opposed to occuring at many different places
;		//  through the code at the point of use.  By limiting the switch to this one point
;		//  we make it much easier to test the code and insure that it is working.  In a
;		//  system for which reliability is important, this is worth the loss of 0.025% of
;		//  the disk space.  A secondary benefit is that this avoids the access time penalty
;		//  which is imposed when we try to use the last few allocation units on a disk
;
;		//  A disk failure that prevents pc_free from working will leave the
;		//  blocks_free variable set at -1
;		logger_disk_power_disk_on ();
^^^^^^^^^^^^^^^	jsr	_logger_disk_power_disk_on
;
;		blocks_free = -1;
^^	move.l	#-1,-4(a6)
;		critical_error_reset ();
^	jsr	_critical_error_reset
;		pc_free(logger_disk_get_partition(), &blocks_total, &blocks_free);
^	pea	-4(a6)
	pea	-8(a6)
	jsr	_logger_disk_get_partition
	move.l	d0,-(sp)
	jsr	_pc_free
;		//  A block is 512 bytes - resets with 40 MB left
;		if (blocks_free < 81920L)  {
^^	cmp.l	#81920,-4(a6)
	lea	12(sp),sp
	bcc	.10036
;			//  The next_partition() routine will depower the current disk
;			log_printf ("disk_access: disk '%s' has only %ld blocks free; switching.\n",
^^;													logger_disk_get_partition(), blocks_free);
	move.l	-4(a6),-(sp)
	jsr	_logger_disk_get_partition
	move.l	d0,-(sp)
	pea	.11+0
	jsr	_log_printf
;																
;			printf ("disk_access: disk '%s' has only %ld blocks free; switching.\n",
^^^;													logger_disk_get_partition(), blocks_free);
	move.l	-4(a6),-(sp)
	jsr	_logger_disk_get_partition
	move.l	d0,-(sp)
	pea	.11+61
	jsr	_printf
;													
;			if (logger_disk_next_partition () < 0)  {
^^^	jsr	_logger_disk_next_partition
	tst.w	d0
	lea	24(sp),sp
	bge	.10037
;				//  REVIEW
;				//  All out of disks.
;				//  Should probably run through the disks and double check everything
;				//  here just to be sure we didn't accidentally abandon a disk due to
;				//  a programing error
;				supervisor.disks_full = 1;
^^^^^^	move.w	#1,_supervisor+130
;				printf ("disk_access: out of disks\n");				
^	pea	.11+122
	jsr	_printf
;				//  break through for loop so we can reset the frequency
;				break;
^^	add.w	#4,sp
	bra	.10034
;			}
^;			eng_logger_disk_switch ();
.10037
^	jsr	_eng_logger_disk_switch
;		}
^;
;		//  flush the text log file to disk, switching disks if needed
;		do  {
.10036
^^^.10040
;			#ifdef DEBUG
;				printf ("disk_access: flushing text log\n");
;			#endif	
;			error = log_flush (NULL);
^^^^	clr.l	-(sp)
	jsr	_log_flush
	move.w	d0,d2
;			if (error)  {	
^	tst.w	d2
	add.w	#4,sp
	beq	.10041
;				//  We might also switch disks if we get an unrecoverable error on the current disk,
;				//  even though that disk is not full.
;				if (logger_disk_next_partition () < 0)  {
^^^	jsr	_logger_disk_next_partition
	tst.w	d0
	bge	.10042
;					//  REVIEW
;					//  all out of disks.
;					supervisor.disks_full = 1;
^^^	move.w	#1,_supervisor+130
;					error = 1;
^	move.l	#1,d2
;					break;
^	bra	.10039
;				}
^;				eng_logger_disk_switch ();
.10042
^	jsr	_eng_logger_disk_switch
;			}
^;		}  while (error != 0);		
.10041
^.10038
	tst.w	d2
	bne	.10040
.10039
;		if (error != 0)
^;			break;
	tst.w	d2
	bne	.10034
;			
;			
;		//  flush the engineering logger to disk, switching disks if needed
;		do  {
^^^^^.10045
;			#ifdef DEBUG
;				printf ("disk_access: flushing engineering log\n");
;			#endif	
;			error = eng_logger_write_disk ();
^^^^	jsr	_eng_logger_write_disk
	move.w	d0,d2
;			if (error)  {	
^	tst.w	d2
	beq	.10046
;				//  This error can occur if the disk is bad or if we are out of disks
;				if (logger_disk_next_partition () < 0)  {
^^	jsr	_logger_disk_next_partition
	tst.w	d0
	bge	.10047
;					//  REVIEW
;					//  all out of disks.
;					supervisor.disks_full = 1;
^^^	move.w	#1,_supervisor+130
;					error = 1;
^	move.l	#1,d2
;					break;
^	bra	.10044
;				}
^;				eng_logger_disk_switch ();
.10047
^	jsr	_eng_logger_disk_switch
;			}
^;		}  while (error != 0);
.10046
^.10043
	tst.w	d2
	bne	.10045
.10044
;		if (error != 0)
^;			break;
	tst.w	d2
	bne	.10034
;		
;		//  flush the science data to disk, switching disks if needed
;		do  {
^^^^.10050
;			#ifdef DEBUG
;				printf ("disk_access: flushing science log\n");
;			#endif	
;			error = sci_logger_write_disk ();;
^^^^	jsr	_sci_logger_write_disk
	move.w	d0,d2
;			if (error)  {	
^	tst.w	d2
	beq	.10051
;				//  This error can occur if the disk is bad or if we are out of disks
;				if (logger_disk_next_partition () < 0)  {
^^	jsr	_logger_disk_next_partition
	tst.w	d0
	bge	.10052
;					//  REVIEW
;					//  all out of disks.
;					supervisor.disks_full = 1;
^^^	move.w	#1,_supervisor+130
;					break;
^	bra	.10049
;				}
^;				eng_logger_disk_switch ();
.10052
^	jsr	_eng_logger_disk_switch
;			}
^;		}  while (error != 0);
.10051
^.10048
	tst.w	d2
	bne	.10050
.10049
;		if (error != 0)
^;			break;
	tst.w	d2
	bne	.10034
;			
;		//  flush the text log file to disk one more time, just to cover any log
;		//  messages which were generated while writing the science or engineering
;		//  logs
;		do  {
^^^^^^.10055
;			#ifdef DEBUG
;				printf ("disk_access: flushing text log\n");
;			#endif	
;			error = log_flush (NULL);
^^^^	clr.l	-(sp)
	jsr	_log_flush
	move.w	d0,d2
;			if (error)  {	
^	tst.w	d2
	add.w	#4,sp
	beq	.10056
;				//  We might also switch disks if we get an unrecoverable error on the current disk,
;				//  even though that disk is not full.
;				if (logger_disk_next_partition () < 0)  {
^^^	jsr	_logger_disk_next_partition
	tst.w	d0
	bge	.10057
;					//  REVIEW
;					//  all out of disks.
;					supervisor.disks_full = 1;
^^^	move.w	#1,_supervisor+130
;					error = 1;
^	move.l	#1,d2
;					break;
^	bra	.10054
;				}
^;				eng_logger_disk_switch ();
.10057
^	jsr	_eng_logger_disk_switch
;			}
^;		}  while (error != 0);		
.10056
^.10053
	tst.w	d2
	bne	.10055
.10054
;
;		break;			
^^	bra	.10034
;	}       
^.10033
	bra	.10035
.10034
;
;	//  power down the disk(s)
;	//  REVIEW
;	//  There is something funny about the way a disk actually moves
;	//  data from its semiconductor buffer to the disk itself.  Some disks
;	//  do not immediately flush the data from the buffer to the disk.  If
;	//  the disk is powered down before it is flushed, the data is lost.
;	//  We try to force a flush before we power down the disk by having 
;	//  the power off routine read back the first part of the log file.
;	//  This is gross and perhaps unreliable.  Investigate better
;	//  solutions and fix this.
;	logger_disk_power_disk_off ();
^^^^^^^^^^^^	jsr	_logger_disk_power_disk_off
;				
;	//  be sure to restore the frequency and baud if needed
;	if (freq_change)  {
^^^	tst.w	d6
	beq	.10058
;		SimSetFSys (freq);
^	move.l	d4,-(sp)
	jsr	_SimSetFSys
;		SerSetBaud (baud, 0L);
^	clr.l	-(sp)
	move.l	d5,-(sp)
	jsr	_SerSetBaud
;	}
^;	
;	if (supervisor.disks_full)  {
	lea	12(sp),sp
.10058
^^	tst.w	_supervisor+130
	beq	.10059
;		log_printf ("disks_full is set.\n");
^	pea	.11+149
	jsr	_log_printf
;		log_printf ("About to enter low power mode.\n");
^	pea	.11+169
	jsr	_log_printf
;		#ifdef NDEBUG
;			printf ("disks_full is set.\n");
^^	pea	.11+201
	jsr	_printf
;			printf ("About to enter low power mode.\n");
^	pea	.11+221
	jsr	_printf
;		#endif	
;		logger_disk_final_flush ();
^^	jsr	_logger_disk_final_flush
;						
;		//  REVIEW - if the disks are full we should disable the
;		//  logger to save power.  A more sophisticated solution
;		//  might be called for.  If we do this, we may as well turn
;		//  the clock down as well.  Maybe we should call a special
;		//  "all_done" routine.  The concern is that we would accidently
;		//  call it when we weren't really dead yet.
;		logger_suspend (MAX_SUSPENSION_TIME);
^^^^^^^^	pea	43200
	jsr	_logger_suspend
;
;		//  The following routine does not return until a character is
;		//  received over the RS232 interface
;		low_power_start_sleep ();
^^^^	jsr	_low_power_start_sleep
;	}
^;
;	#if defined(DEBUG) && !defined(SIMULATE_DATA)
;	printf ("disk_access finishing at: ");
;	cmd_print_time (NULL);
;	stop_time = logger_time_get_time ();
;	dT = ttmcmp (stop_time, start_time);
;	printf ("%ld.", dT/GetTickRate());
;	printf ("%03d sec disk access time\n", (int)(1000.0*(dT%GetTickRate()) / GetTickRate()));
;    #endif
;
;	#ifdef SIMULATE_DATA
;	dT = StopWatchTime ();
;	log_printf ("%ld.", (long)(dT/1000000L));
;	log_printf ("%03d sec disk access time\n", (int)((dT%1000000L)/1000));
;	#ifndef DEBUG
;	printf ("%ld.", (long)(dT/1000000L));
;	printf ("%03d sec disk access time\n", (int)((dT%1000000L)/1000));
;	#endif
;	if ((dT/1000000L) > 60)  {
;		log_printf ("disk_access: likely disk overflow\n");
;		printf ("disk_access: likely disk overflow\n");
;	}
;	#endif
;
;	return 1;       
	lea	20(sp),sp
.10059
^^^^^^^^^^^^^^^^^^^^
^^^^^	move.l	#1,d0
	bra	.17
;}       
^.15
.16	equ	-8
.11
	dc.b	100,105,115,107,95,97,99,99,101,115,115,58,32,100,105
	dc.b	115,107,32,39,37,115,39,32,104,97,115,32,111,110,108
	dc.b	121,32,37,108,100,32,98,108,111,99,107,115,32,102,114
	dc.b	101,101,59,32,115,119,105,116,99,104,105,110,103,46,10
	dc.b	0,100,105,115,107,95,97,99,99,101,115,115,58,32,100
	dc.b	105,115,107,32,39,37,115,39,32,104,97,115,32,111,110
	dc.b	108,121,32,37,108,100,32,98,108,111,99,107,115,32,102
	dc.b	114,101,101,59,32,115,119,105,116,99,104,105,110,103,46
	dc.b	10,0,100,105,115,107,95,97,99,99,101,115,115,58,32
	dc.b	111,117,116,32,111,102,32,100,105,115,107,115,10,0,100
	dc.b	105,115,107,115,95,102,117,108,108,32,105,115,32,115,101
	dc.b	116,46,10,0,65,98,111,117,116,32,116,111,32,101,110
	dc.b	116,101,114,32,108,111,119,32,112,111,119,101,114,32,109
	dc.b	111,100,101,46,10,0,100,105,115,107,115,95,102,117,108
	dc.b	108,32,105,115,32,115,101,116,46,10,0,65,98,111,117
	dc.b	116,32,116,111,32,101,110,116,101,114,32,108,111,119,32
	dc.b	112,111,119,101,114,32,109,111,100,101,46,10,0
	ds	0
;
;
;
;
;
;//  assembler routines to allow access to variables which define how
;//  the memory is used
;#asm
;;:ts=8
;;
;	dseg
;	public  __stkbase
;	public  STKSIZ
;	public  __H0_org
;	public  __H0_end
;	cseg
;	public  _get_stkbase
;	public  _get_STKSIZ
;	public  _get_code_start
;	public  _get_code_end
;
;_get_stkbase:
;	move.l  __stkbase,d0
;	rts
;	
;_get_STKSIZ:
;	move.l  STKSIZ,d0
;	rts
;
;_get_code_start:
;	move.l  __H0_org,d0
;	rts
;	
;_get_code_end:
;	move.l  __H0_end,d0
;	rts
;	
;#endasm
;:ts=8
;
	dseg
	public  __stkbase
	public  STKSIZ
	public  __H0_org
	public  __H0_end
	cseg
	public  _get_stkbase
	public  _get_STKSIZ
	public  _get_code_start
	public  _get_code_end

_get_stkbase:
	move.l  __stkbase,d0
	rts
	
_get_STKSIZ:
	move.l  STKSIZ,d0
	rts

_get_code_start:
	move.l  __H0_org,d0
	rts
	
_get_code_end:
	move.l  __H0_end,d0
	rts
	
;
;
;//  print_CRC
;//
;//      Debugging routine only, calculates a CRC so we can verify that there were
;//  no accidental code overwrites during execution
;//
;void print_CRC (void)  {
# 721
| .19
	xdef	_print_CRC
_print_CRC:
;	//  calculate a crc on our code so as to help catch overwrite bugs
;	log_printf ("TOM8 monitor CRC = 0x%04X\n", CalcCRC ((uchar*)0x0, 0x176FL, 0));
^^	clr.w	-(sp)
	pea	5999
	clr.l	-(sp)
	jsr	_CalcCRC
	lea	10(sp),sp
	move.w	d0,-(sp)
	pea	.18+0
	jsr	_log_printf
;	#ifndef DEBUG
;		printf ("TOM8 monitor CRC = 0x%04X\n", CalcCRC ((uchar*)0x0, 0x176FL, 0));
^^	clr.w	-(sp)
	pea	5999
	clr.l	-(sp)
	jsr	_CalcCRC
	lea	10(sp),sp
	move.w	d0,-(sp)
	pea	.18+27
	jsr	_printf
;	#endif	
;//	log_printf ("Data logger CRC = 0x%04X\n", CalcCRC ((uchar*)0x2C2000, 0x225C4L, 0));
;}
^^^	lea	12(sp),sp
.20
	rts
.19
.18
	dc.b	84,79,77,56,32,109,111,110,105,116,111,114,32,67,82
	dc.b	67,32,61,32,48,120,37,48,52,88,10,0,84,79,77
	dc.b	56,32,109,111,110,105,116,111,114,32,67,82,67,32,61
	dc.b	32,48,120,37,48,52,88,10,0
	ds	0
;
;
;
;#ifdef DEBUG
;
;void debug_init (void)  {
;    char* cp;
;    
;	print_CRC ();
;	cp = get_stkbase ();
;	printf ("The stack base is at 0x%08lX\n", (long)cp);
;	//  Skip the first 4 chars because the stkchk routine uses them
;	//  to monitor for stack overflow
;	cp += 4;
;	while (cp < (char*)GetStackPtr ())  {
;		*cp++ = (char)0xCC;
;	}
;	
;	return;
;}
;
;
;
;
;void debug_end (void)  {
;    char* cp;
;    long delta;
;    long stack_size;
;    
;	print_CRC ();
;
;	//  check how much of the stack was actually used by looking for our
;	//  fill character.  There is apparently no good way to id what the
;	//  actual stack size is.  The linker defined public STKSIZ doesn't
;	//  seem to work.
;	cp = (char*)get_stkbase ();
;	cp += 4;
;	if ((cp == (char*)0x2C0000L) || (cp == (char*)0x202000L))
;		stack_size = 0x2000;
;	else    
;		stack_size = 0x4000;
;	
;	while ((*cp == (char)0xCC) && (cp < (char*)GetStackPtr ()))
;		cp++;
;	delta = (long)cp - (long)get_stkbase();
;	printf ("There were %ld bytes of stack space remaining.\n", delta);
;	printf ("Apparent usage was %ld bytes\n", stack_size-delta);
;}
;
;#endif
;		
;
# 779
|
~ _main * "(v"
~ _get_stkbase * "(#c"
~ _print_CRC * "(v"
~ _disk_access * "(i"
~ _collect_data * "(v"
~ _process_COM_input * "(i"
~ _collect_COM_input * "(i"
~ 'supervisor'
~ 2 3 132
~ COM_buffer 0 "[128C"
~ n_in_COM_buffer 128 "i"
~ disks_full 130 "i"
~ _supervisor * ":" 2
~ _MIN_ENG_READ_FREQ * "l"
~ _MIN_TIME_SET_FREQ * "l"
~ _DISK_FREQ * "l"
~ _TT8_clock_freq * "l"
~ _SOFTWARE_VERSION * "f"
~ _PREVIOUS_COMMAND * "C"
~ _critical_error_reset * "(v"
~ _prep_pins_low_power * "(v"
~ _low_power_start_sleep * "(v"
~ _unexpected_int_init * "(v"
~ _log_printf * "(i"
~ _log_flush * "(i"
~ _log_disk_request * "(i"
~ 'text_log'
~ 3 5 1068
~ filename 0 "[32c"
~ data 32 "[1024c"
~ n_data 1056 "i"
~ n_filled 1058 "i"
~ oldest_data 1060 ":" 1
~ _log_power_on_init * "(i"
~ _logger_get_seconds_to_start * "(l"
~ _logger_verify_suspension * "(v"
~ _logger_suspend * "(i"
~ _logger_shutdown * "(v"
~ _command_parse * "(i"
~ _logger_disk_final_flush * "(v"
~ _logger_disk_next_partition * "(i"
~ _logger_disk_get_partition * "(#c"
~ _logger_disk_power_disk_off * "(v"
~ _logger_disk_power_disk_on * "(v"
~ _logger_disk_power_on_init * "(v"
~ 'system_user'
~ 4 4 46
~ task_handle 0 "i"
~ rtfs_errno 2 "i"
~ dfltdrv 4 "i"
~ lcwd 6 "[10#v"
~ PSYSTEM_USER "#:" 4
~ SYSTEM_USER ":" 4
~ 'finode'
~ 'ddrive'
~ 'fatswap'
~ 7 7 300
~ n_to_swap 0 "I"
~ n_blocks_used 2 "I"
~ n_blocks_total 4 "I"
~ pdirty 6 "[32C"
~ block_0_is_valid 38 "i"
~ data_map 40 "[256C"
~ data_array 296 "#C"
~ 6 37 484
~ opencount 0 "i"
~ volume_serialno 2 "L"
~ volume_label 6 "[14C"
~ drv_serial_number 20 "[62C"
~ partition_base 82 "L"
~ partition_size 86 "L"
~ partition_type 90 "C"
~ current_power_count 92 "L"
~ bytespcluster 96 "I"
~ byte_into_cl_mask 98 "L"
~ fasize 102 "I"
~ rootblock 104 "L"
~ firstclblock 108 "L"
~ driveno 112 "I"
~ maxfindex 114 "L"
~ fatblock 118 "L"
~ secproot 122 "I"
~ fat_is_dirty 124 "i"
~ fat_swap_structure 126 ":" 7
~ bootaddr 426 "L"
~ oemname 430 "[9c"
~ bytspsector 440 "I"
~ secpalloc 442 "C"
~ log2_secpalloc 444 "I"
~ secreserved 446 "I"
~ numfats 448 "C"
~ numroot 450 "I"
~ numsecs 452 "L"
~ mediadesc 456 "C"
~ secpfat 458 "L"
~ secptrk 462 "I"
~ numhead 464 "I"
~ numhide 466 "L"
~ free_contig_base 470 "L"
~ free_contig_pointer 474 "L"
~ known_free_clusters 478 "l"
~ infosec 482 "I"
~ 'segdesc'
~ 8 4 14
~ nsegs 0 "i"
~ segindex 2 "i"
~ ncksum 4 "C"
~ segblock 6 "[2L"
~ 5 18 72
~ fname 0 "[8C"
~ fext 8 "[3C"
~ fattribute 11 "C"
~ resarea 12 "[8C"
~ fclusterhi 20 "I"
~ ftime 22 "I"
~ fdate 24 "I"
~ fcluster 26 "I"
~ fsize 28 "L"
~ alloced_size 32 "L"
~ opencount 36 "i"
~ openflags 38 "i"
~ my_drive 40 "#:" 6
~ my_block 44 "L"
~ my_index 48 "i"
~ pnext 50 "#:" 5
~ pprev 54 "#:" 5
~ s 58 ":" 8
~ 'drobj'
~ 'dirblk'
~ 10 3 10
~ my_frstblock 0 "L"
~ my_block 4 "L"
~ my_index 8 "i"
~ 'blkbuff'
~ 11 7 532
~ pnext 0 "#:" 11
~ lru 4 "L"
~ pdrive 8 "#:" 6
~ blockno 12 "L"
~ use_count 16 "i"
~ pad_to_4_align 18 "i"
~ data 20 "[512C"
~ 9 5 24
~ pdrive 0 "#:" 6
~ finode 4 "#:" 5
~ blkinfo 8 ":" 10
~ isroot 18 "i"
~ pblkbuff 20 "#:" 11
~ 'datestr'
~ 12 2 4
~ date 0 "I"
~ time 2 "I"
~ 'pc_file'
~ 13 8 24
~ pobj 0 "#:" 9
~ flag 4 "I"
~ fptr 6 "L"
~ fptr_cluster 10 "L"
~ fptr_block 14 "L"
~ needs_flush 18 "i"
~ is_free 20 "i"
~ at_eof 22 "i"
~ 'block_alloc'
~ 14 1 512
~ core 0 "[512C"
~ 'ptable'
~ 'ptable_entry'
~ 16 8 16
~ boot 0 "C"
~ s_head 1 "C"
~ s_cyl 2 "I"
~ p_typ 4 "C"
~ e_head 5 "C"
~ e_cyl 6 "I"
~ r_sec 8 "L"
~ p_size 12 "L"
~ 15 2 66
~ ents 0 "[4:" 16
~ signature 64 "I"
~ PTABLE ":" 15
~ PTABLE_ENTRY ":" 16
~ 'format_dec_tree'
~ 17 3 8
~ sec_p_alloc 0 "I"
~ ents_p_root 2 "I"
~ n_blocks 4 "L"
~ FORMAT_DEC_TREE ":" 17
~ PC_FILE ":" 13
~ DROBJ ":" 9
~ BLKBUFF ":" 11
~ DIRBLK ":" 10
~ FINODE ":" 5
~ SEGDESC ":" 8
~ 'lfninode'
~ 18 8 32
~ lfnorder 0 "C"
~ lfname1 1 "[10C"
~ lfnattribute 11 "C"
~ lfnres 12 "C"
~ lfncksum 13 "C"
~ lfname2 14 "[12C"
~ lfncluster 26 "I"
~ lfname3 28 "[4C"
~ LFNINODE ":" 18
~ 'dosinode'
~ 19 9 32
~ fname 0 "[8C"
~ fext 8 "[3C"
~ fattribute 11 "C"
~ resarea 12 "[8C"
~ fclusterhi 20 "I"
~ ftime 22 "I"
~ fdate 24 "I"
~ fcluster 26 "I"
~ fsize 28 "L"
~ DOSINODE ":" 19
~ DDRIVE ":" 6
~ FATSWAP ":" 7
~ BLOCK_ALLOC ":" 14
~ CLUSTERTYPE "L"
~ 'ide_control'
~ 'ide_drive_desc'
~ ''
~ 'atapi_packet_desc'
~ 'transfer_length'
~ 24 2 2
~ msb 0 "C"
~ lsb 1 "C"
~ 23 8 14
~ op_code 0 "C"
~ lun 1 "C"
~ lba 2 "L"
~ reserved1 6 "C"
~ transfer_length 8 ":" 24
~ reserved2 10 "C"
~ reserved3 11 "C"
~ reserved4 12 "C"
~ 'atapi_mode_sense_packet_desc'
~ 25 11 14
~ op_code 0 "C"
~ lun 1 "C"
~ pc_code_page 2 "C"
~ reserved1 3 "C"
~ reserved2 4 "C"
~ reserved3 5 "C"
~ reserved4 6 "C"
~ transfer_length 8 ":" 24
~ reserved5 10 "C"
~ reserved6 11 "C"
~ reserved7 12 "C"
~ 'atapi_format_unit_packet_desc'
~ 26 5 12
~ op_code 0 "C"
~ defect_list_format 1 "C"
~ track_number 2 "C"
~ interleave 3 "[2C"
~ reserved 5 "[7C"
~ 'atapi_old_format_unit_packet_de'
~ 27 7 12
~ op_code 0 "C"
~ reserved1 1 "C"
~ medium 2 "C"
~ reserved2 3 "[3C"
~ control_byte 6 "C"
~ track_number 7 "C"
~ reserved3 8 "[4C"
~ 'atapi_start_stop_packet_desc'
~ 28 6 12
~ op_code 0 "C"
~ lun 1 "C"
~ reserved1 2 "C"
~ reserved2 3 "C"
~ eject 4 "C"
~ reserved 5 "[7C"
~ 22 5 14
~ generic 0 ":" 23
~ mode_sense 0 ":" 25
~ format 0 ":" 26
~ old_format 0 ":" 27
~ start_stop 0 ":" 28
~ 21 17 48
~ num_heads 0 "C"
~ sec_p_track 1 "C"
~ sec_p_cyl 2 "I"
~ num_cylinders 4 "I"
~ max_multiple 6 "C"
~ supports_lba 8 "i"
~ total_lba 10 "L"
~ enable_mapping 14 "i"
~ media_changed 16 "i"
~ volume_start 18 "L"
~ volume_end 22 "L"
~ protocol 26 "C"
~ atapi_packet 28 ":" 22
~ atapi_packet_size 42 "I"
~ media_descriptor 44 "C"
~ medium_type_code 45 "C"
~ allocation_unit 46 "C"
~ 20 29 138
~ opencount 0 "i"
~ register_file_address 2 "#I"
~ interrupt_number 6 "i"
~ controller_number 8 "i"
~ command_complete 10 "i"
~ error_code 12 "I"
~ timer 14 "I"
~ block_size 16 "C"
~ sectors_remaining 18 "I"
~ user_address 20 "#C"
~ drive 24 "[2:" 21
~ vo_write_precomp 120 "C"
~ vo_sector_count 121 "C"
~ vo_sector_number 122 "C"
~ vo_cyl_low 123 "C"
~ vo_cyl_high 124 "C"
~ vo_drive_head 125 "C"
~ vo_feature 126 "C"
~ vo_command 127 "C"
~ vo_dig_out 128 "C"
~ vi_error 129 "C"
~ vi_sector_count 130 "C"
~ vi_sector_number 131 "C"
~ vi_cyl_low 132 "C"
~ vi_cyl_high 133 "C"
~ vi_drive_head 134 "C"
~ vi_status 135 "C"
~ vi_alt_status 136 "C"
~ vi_drive_addr 137 "C"
~ PIDE_CONTROLLER "#:" 20
~ IDE_CONTROLLER ":" 20
~ IDE_DRIVE_DESC ":" 21
~ ATAPI_PACKET ":" 22
~ ATAPI_PACKET_DESC ":" 23
~ ATAPI_OLD_FORMAT_UNIT_PACKET_DE ":" 27
~ ATAPI_START_STOP_UNIT_PACKET_DE ":" 28
~ ATAPI_FORMAT_UNIT_PACKET_DESC ":" 26
~ ATAPI_MODE_SENSE_PACKET_DESC ":" 25
~ 'Himawari_format_descriptor'
~ 'Himawari_defect_list_header'
~ 30 4 4
~ reserved 0 "C"
~ control_byte 1 "C"
~ length_msb 2 "C"
~ length_lsb 3 "C"
~ 'Himawari_formattable_capacity_d'
~ 31 3 8
~ number_of_blocks 0 "[4C"
~ reserved 4 "C"
~ block_length 5 "[3C"
~ 29 2 12
~ dlheader 0 ":" 30
~ capacity_descriptor 4 ":" 31
~ HIMAWARI_FORMAT_DESCRIPTOR ":" 29
~ HIMAWARI_FORMATTABLE_CAPACITY_D ":" 31
~ HIMAWARI_DEFECT_LIST_HEADER ":" 30
~ 'himawari_flexible_disk_page'
~ 32 17 32
~ page_code 0 "C"
~ page_length 1 "C"
~ transfer_rate_msb 2 "C"
~ transfer_rate_lsb 3 "C"
~ number_of_heads 4 "C"
~ sectors_per_track 5 "C"
~ bytes_per_cylinder_msb 6 "C"
~ bytes_per_cylinder_lsb 7 "C"
~ number_of_cylinders_msb 8 "C"
~ number_of_cylinders_lsb 9 "C"
~ reserved1 10 "[10C"
~ motor_off_delay 20 "C"
~ swp_swpp 21 "C"
~ reserved2 22 "[6C"
~ medium_rotation_rate_msb 28 "C"
~ medium_rotation_rate_lsb 29 "C"
~ reserved3 30 "[2C"
~ HIMAWARI_FLEXIBLE_DISK_PAGE ":" 32
~ TRANSFER_LENGTH ":" 24
~ BLOCKT "L"
~ _init_IDE * "(v"
~ _pc_free * "(l"
~ 'fmtparms'
~ 33 15 52
~ oemname 0 "[9c"
~ secpalloc 9 "C"
~ secreserved 10 "I"
~ numfats 12 "C"
~ secpfat 14 "L"
~ fmttype 18 "C"
~ numhide 20 "L"
~ numroot 24 "I"
~ mediadesc 26 "C"
~ secptrk 28 "I"
~ numhead 30 "I"
~ numcyl 32 "I"
~ physical_drive_no 34 "C"
~ binary_volume_label 36 "L"
~ text_volume_label 40 "[12c"
~ FMTPARMS ":" 33
~ 'freelistinfo'
~ 34 2 8
~ cluster 0 "L"
~ nclusters 4 "l"
~ FREELISTINFO ":" 34
~ 'fileseginfo'
~ 35 2 8
~ block 0 "l"
~ nblocks 4 "l"
~ FILESEGINFO ":" 35
~ 'stat'
~ 36 12 38
~ st_dev 0 "i"
~ st_ino 2 "i"
~ st_mode 4 "L"
~ st_nlink 8 "i"
~ st_rdev 10 "i"
~ st_size 12 "L"
~ st_atime 16 ":" 12
~ st_mtime 20 ":" 12
~ st_ctime 24 ":" 12
~ st_blksize 28 "l"
~ st_blocks 32 "l"
~ fattribute 36 "C"
~ STAT ":" 36
~ 'dstat'
~ 37 14 578
~ fname 0 "[9c"
~ fext 9 "[4c"
~ lfname 13 "[256C"
~ filename 269 "[15c"
~ fattribute 284 "C"
~ ftime 286 "I"
~ fdate 288 "I"
~ fsize 290 "L"
~ driveno 294 "i"
~ pname 296 "[9C"
~ pext 305 "[4C"
~ path 309 "[260c"
~ pobj 570 "#v"
~ pmom 574 "#v"
~ DSTAT ":" 37
~ DATESTR ":" 12
~ PCFD "i"
~ UNICODE "I"
~ IOADDRESS "#I"
~ PFCBYTE "#C"
~ PFCCHAR "#c"
~ PFVOID "#v"
~ PFCHAR "#c"
~ PFDWORD "#L"
~ PFLONG "#l"
~ PFWORD "#I"
~ PFINT "#i"
~ PFBYTE "#C"
~ BOOLEAN "i"
~ dword "L"
~ word "I"
~ byte "C"
~ _logger_time_set_tick_offset * "(v"
~ _logger_time_verify_set * "(i"
~ _logger_time_get_string * "(#c"
~ _logger_time_power_on_init * "(v"
~ EARLIEST_LOGGER_TIME _EARLIEST_LOGGER_TIME ":" 1
~ LATEST_LOGGER_TIME _LATEST_LOGGER_TIME ":" 1
~ _eeprom_read_setup_data * "(i"
~ 'setup_variables'
~ 38 13 82
~ eng_rate 0 "[4l"
~ science_rate 16 "f"
~ science_gain 20 "[4f"
~ science_chans 36 "i"
~ trigger_chans 38 "i"
~ t_STA 40 "f"
~ t_LTA 44 "f"
~ trigger_level 48 "[4f"
~ post_event_time 64 "f"
~ pre_event_time 68 "f"
~ min_disk_write 72 "l"
~ science_n_to_average 76 "i"
~ tick_offset 78 "l"
~ _setup_data * ":" 38
~ _eng_logger_disk_switch * "(v"
~ _eng_logger_disk_request * "(i"
~ _eng_logger_write_disk * "(i"
~ _eng_logger_collect * "(i"
~ _eng_logger_power_on_init * "(v"
~ _sci_logger_write_disk * "(i"
~ _sci_logger_overflow_check * "(v"
~ _sci_logger_disk_request * "(i"
~ _sci_logger_set_binary_preview * "(v"
~ _sci_logger_set_ASCII_preview * "(v"
~ _sci_logger_collect * "(i"
~ _sci_logger_power_on_init * "(v"
~ _MAX186_power_on_init * "(v"
~ _AD7716_power_on_init * "(v"
~ ''
~ 39 2 8
~ quot 0 "l"
~ rem 4 "l"
~ ''
~ 40 2 4
~ quot 0 "i"
~ rem 2 "i"
~ ldiv_t ":" 39
~ div_t ":" 40
~ '__stdio'
~ 41 8 22
~ _bp 0 "#C"
~ _bend 4 "#C"
~ _buff 8 "#C"
~ _flags 12 "I"
~ _unit 14 "c"
~ _bytbuf 15 "C"
~ _buflen 16 "L"
~ _tmpnum 20 "I"
~ _printf * "(i"
~ _fflush * "(i"
~ __iob * "[0:" 41
~ FILE ":" 41
~ fpos_t "l"
~ va_list "#c"
~ ''
~ 42 13 46
~ libVersion 0 "l"
~ ramBase 4 "#c"
~ ramSize 8 "l"
~ ramWaits 12 "i"
~ flashBase 14 "#c"
~ flashSize 18 "l"
~ flashWaits 22 "i"
~ heapBot 24 "#v"
~ heapTop 28 "#v"
~ heapCur 32 "#v"
~ statusReg 36 "I"
~ vectorBase 38 "#v"
~ stackPtr 42 "#v"
~ infoAction "c"
~ TT8info ":" 42
~ _InitTT8 * "(v"
~ UeeErr "c"
~ _ttmnow * "(:" 1
~ _StopWatchTime * "(L"
~ _DelayMilliSecs * "(v"
~ _SimGetFSys * "(l"
~ _SimSetFSys * "(l"
~ time_tt ":" 1
~ _SerActivate * "(v"
~ _SerShutDown * "(v"
~ _SerSetBaud * "(l"
~ _SerGetBaud * "(l"
~ _SerByteAvail * "(i"
~ _SerGetByte * "(i"
~ XmdmErr "c"
~ FlashErr "c"
~ ''
~ 43 4 24
~ eSR 0 "I"
~ ePC 2 "L"
~ vectofs 6 "I"
~ states 8 "[8I"
~ ''
~ 44 4 20
~ preamble 0 "[4I"
~ jump 8 "I"
~ target 10 "L"
~ postamble 14 "[3I"
~ ExcCFramePtr "#:" 44
~ ExcCFrame ":" 44
~ ExcStackFrame ":" 43
~ _CalcCRC * "(I"
~ 'tm'
~ 45 10 20
~ tm_sec 0 "i"
~ tm_min 2 "i"
~ tm_hour 4 "i"
~ tm_mday 6 "i"
~ tm_mon 8 "i"
~ tm_year 10 "i"
~ tm_wday 12 "i"
~ tm_yday 14 "i"
~ tm_isdst 16 "i"
~ tm_hsec 18 "i"
~ time_t "L"
~ clock_t "L"
~ wchar_t "c"
~ ptrdiff_t "l"
~ size_t "L"
~ PSPErr "c"
~ _PRAM "[8I"
~ bool "c"
~ vfptr "#(v"
~ ptr "#c"
~ ulpv "#L"
~ ulong "L"
~ uspv "#I"
~ unsint "I"
~ ushort "I"
~ ucpv "#C"
~ uchar "C"
	xref	_get_stkbase
	xref	_critical_error_reset
	xref	_prep_pins_low_power
	xref	_low_power_start_sleep
	xref	_unexpected_int_init
	xref	_log_printf
	xref	_log_flush
	xref	_log_disk_request
	xref	_log_power_on_init
	xref	_logger_get_seconds_to_start
	xref	_logger_verify_suspension
	xref	_logger_suspend
	xref	_logger_shutdown
	xref	_command_parse
	xref	_logger_disk_final_flush
	xref	_logger_disk_next_partition
	xref	_logger_disk_get_partition
	xref	_logger_disk_power_disk_off
	xref	_logger_disk_power_disk_on
	xref	_logger_disk_power_on_init
	xref	_init_IDE
	xref	_pc_free
	xref	_logger_time_set_tick_offset
	xref	_logger_time_verify_set
	xref	_logger_time_get_string
	xref	_logger_time_power_on_init
	xref	_eeprom_read_setup_data
	xref	_eng_logger_disk_switch
	xref	_eng_logger_disk_request
	xref	_eng_logger_write_disk
	xref	_eng_logger_collect
	xref	_eng_logger_power_on_init
	xref	_sci_logger_write_disk
	xref	_sci_logger_overflow_check
	xref	_sci_logger_disk_request
	xref	_sci_logger_set_binary_preview
	xref	_sci_logger_set_ASCII_preview
	xref	_sci_logger_collect
	xref	_sci_logger_power_on_init
	xref	_MAX186_power_on_init
	xref	_AD7716_power_on_init
	xref	_printf
	xref	_fflush
	xref	_InitTT8
	xref	_ttmnow
	xref	_StopWatchTime
	xref	_DelayMilliSecs
	xref	_SimGetFSys
	xref	_SimSetFSys
	xref	_SerActivate
	xref	_SerShutDown
	xref	_SerSetBaud
	xref	_SerGetBaud
	xref	_SerByteAvail
	xref	_SerGetByte
	xref	_CalcCRC
	xref	.begin
	dseg
	global	_supervisor,132
	xref	_setup_data
	xref	__iob
	end
