/* vim: set filetype=c:
 *
 * printscan.c86  -  Print the result of the memory scan
 *
 * Copyright (C) 1998-2007 Gero Kuhlmann   <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: printscan.c86,v 1.5 2007/01/06 18:31:21 gkminix Exp $
 */

#include <common.h86>
#include <i386/conio.h86>
#include "romcheck.h86"




/*
 * Print the result of the memory scan. First print all signature areas,
 * and then an overview of physical memory in one line.
 */
void printscan(const struct scaninfo *sip)
{
  unsigned short seg, step;
  unsigned short i;

  printf("\n\nResults of memory scan:\n\n");

  /* First print result of signature scan */
  step = (ENDSEG - STARTSEG) / sip->romsize;
  for (i = 0; i < sip->signum; i++) {
	printf("%4hu      ", i + 1);
	for (seg = STARTSEG; seg < ENDSEG; seg += step) {
		if (seg < sip->sigsegs[i] ||
		    seg >= sip->sigsegs[i] + sip->sigsize[i])
			putchar(CHAR_DASH);
		else if (sip->sigvalid[i])
			putchar(CHAR_VALID);
		else
			putchar(CHAR_INVALID);
	}
	printf("    [%3hu kB]\n", sip->sigsize[i] / 64);
  }

  /* Now print the physical memory layout */
  printf("\nPhysical  ");
  for (i = 0; i < sip->romsize; i++) {
	switch (sip->rombuf[i]) {
		case TYPE_RAM:
			putchar(CHAR_RAM);
			break;
		case TYPE_ROM:
			putchar(CHAR_ROM);
			break;
		case TYPE_EMPTY:
			putchar(CHAR_EMPTY);
			break;
		case TYPE_UNKNOWN:
		default:
			putchar(CHAR_UNKNOWN);
			break;
	}
  }
  printf("\nEvery box represents %u kB, starting at segment %04X\n",
			(ENDSEG - STARTSEG) / (sip->romsize * 64), STARTSEG);
}

