/*
 *  siminfo2.c
 *
 *  This program tests the C structure representing the System
 *  Integration Module on the MCF5307
 *
 *  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.                              
 */
#ifndef MCF5307
  #error "You can only run siminfo2 on a MCF5307"
#endif

#include <stdio.h>

#include "sim5307.h"

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

int main()
{
  SIM5307 *sim = (SIM5307 *)0x10000000;
  int     index;

  printf("System Integration Module Info Program\n");
  printf("Copyright (c) 1997-1998 - David Fiddes, D.J.Fiddes@hw.ac.uk\n\n");

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

  printf("Module: SIM - System Integration Module Configuration\n");
  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:    %.4X\n",sim->par);
  printf("  IRQPAR: %.2X\n",sim->irqpar);
  printf("  PLLCR:  %.2X\n",sim->pllcr);
  printf("  MPARK:  %.2X\n",sim->mpark);
  printf("  IPR:    %.8X\n",sim->ipr);
  printf("  IMR:    %.8X\n",sim->imr);
  printf("  AVCR:   %.2X\n",sim->avcr);
  printf("  ICR0:   %.2X\n",sim->icr0);
  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("\n");

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

  for(index=2; (index<8); index++)
  {
    printf("  CSMR%d:  %.8X\n",index,sim->cs_rel[index-2].csmr);
    printf("  CSCR%d:  %.4X\n",index,sim->cs_rel[index-2].cscr);
  }

  printf("\n");

  printf("Module: DRAMC - DRAM controller configuration\n");
  printf("  DCR:    %.4X\n",sim->dcr);
  printf("  DACR0:  %.8X\n",sim->dacr0);
  printf("  DMR0:   %.8X\n",sim->dmr0);
  printf("  DACR1:  %.8X\n",sim->dacr1);
  printf("  DMR1:   %.8X\n",sim->dmr1);
  
  printf("\n");


  printf("Module: GPIO - General Purpose IO\n");
  printf("  PADDR:  %.4X\n",sim->paddr);
  printf("  PADAT:  %.4X\n",sim->padat);

  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);
  for(index=0; (index<4); index++)
  {
    printf("  dma[%d]:  %#X\n",index,(int)&sim->dma[index]);
  }

                      
  printf("\n\nThe End.\n");
  return 0;
}
