/*
 *  siminfo.c
 *
 *  This program tests the C structure representing the System
 *  Integration Module on the MCF5206 and MCF5206e
 *
 *  Author:
 *    David Fiddes, D.J@fiddes.net
 *    http://fiddes.net/coldfire/
 *
 *  This code has no copyright and may freely be used in whatever 
 *  manner you see fit.
 *
 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY 
 *  OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT    
 *  LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR    
 *  FITNESS FOR A PARTICULAR PURPOSE.                              
 */
#ifdef MCF5307
  #error "You can only run siminfo on a MCF5206 or MCF5206e"
#endif

#include <stdio.h>
#include "sim5206.h"

/* We substitute iprintf for printf to avoid bringing in the floating point library */
/* The functions are otherwise equivalent */
#define printf iprintf

int main()
{
  SIM5206 *sim;
  int     index;

  printf("System Integration Module Info Program\n");
  printf("Copyright (c) 1997 - David J. Fiddes\n\n");

  sim = (SIM5206 *)0x10000000;

  printf("Set sim pointer: sim =%#X\n\n",sim);

  printf("Module: SIM - System Integration Module Configuration\n");
  printf("  SIMR:   %.2X\n",sim->simr);
  printf("  ICR1:   %.2X\n",sim->icr1);
  printf("  ICR2:   %.2X\n",sim->icr2);
  printf("  ICR3:   %.2X\n",sim->icr3);
  printf("  ICR4:   %.2X\n",sim->icr4);
  printf("  ICR5:   %.2X\n",sim->icr5);
  printf("  ICR6:   %.2X\n",sim->icr6);
  printf("  ICR7:   %.2X\n",sim->icr7);
  printf("  ICR8:   %.2X\n",sim->icr8);
  printf("  ICR9:   %.2X\n",sim->icr9);
  printf("  ICR10:  %.2X\n",sim->icr10);
  printf("  ICR11:  %.2X\n",sim->icr11);
  printf("  ICR12:  %.2X\n",sim->icr12);
  printf("  ICR13:  %.2X\n",sim->icr13);
  printf("  IMR:    %.4X\n",sim->imr);
  printf("  IPR:    %.4X\n",sim->ipr);
  printf("  RSR:    %.2X\n",sim->rsr);
  printf("  SYPCR:  %.2X\n",sim->sypcr);
  printf("  SWIVR:  %.2X\n",sim->swivr);
  printf("  SWSR:   %.2X\n",sim->swsr);
  printf("  PAR:    %.2X\n",sim->par);

  printf("\n");

  printf("Module: DRAMC - DRAM controller configuration\n");
  printf("  DCRR:   %.4X\n",sim->dcrr);
  printf("  DCTR:   %.4X\n",sim->dctr);
  printf("  DCAR0:  %.4X\n",sim->dcar0);
  printf("  DCMR0:  %.8X\n",sim->dcmr0);
  printf("  DCCR0:  %.2X\n",sim->dccr0);
  printf("  DCAR1:  %.4X\n",sim->dcar1);
  printf("  DCMR1:  %.8X\n",sim->dcmr1);
  printf("  DCCR1:  %.2X\n",sim->dccr1);

  printf("\n");

  printf("Module: CS - Chip Select configuration\n");
  for(index=0; (index<8); index++)
  {
    printf("  CSAR%d:  %.4X\n",index,sim->cs[index].csar);
    printf("  CSMR%d:  %.8X\n",index,sim->cs[index].csmr);
    printf("  CSCR%d:  %.4X\n",index,sim->cs[index].cscr);
  }
  printf("  DMCR:   %.4X\n",sim->dmcr);

  printf("\n");

  printf("Module: GPIO - General Purpose IO\n");
  printf("  PPDDR:  %.2X\n",sim->ppddr);
  printf("  PPDAT:  %.2X\n",sim->ppdat);

  printf("\n");

  printf("Additional Module Offsets\n");
  printf("  timer1 = %#X\n",(int)&sim->timer1);
  printf("  timer2 = %#X\n",(int)&sim->timer2);
  printf("  uart1  = %#X\n",(int)&sim->uart1);
  printf("  uart2  = %#X\n",(int)&sim->uart2);
  printf("  mbus   = %#X\n",(int)&sim->mbus);
                      
  printf("\n\nThe End.\n");
  return 0;
}
