コード例 #1
0
ファイル: fpga.c プロジェクト: rkrajnc/minimig-de1
void SendFile(RAFile *file)
{
    DEBUG_FUNC_IN(DEBUG_F_FPGA | DEBUG_L0);

    unsigned char  c1, c2;
    unsigned long  j;
    unsigned long  n;
    unsigned char *p;

    printf("[");
    n = (file->file.size + 511) >> 9; // sector count (rounded up)
    while (n--)
    {
        // read data sector from memory card
        RARead(file,sector_buffer,512);

        do
        {
            // read FPGA status
            EnableFpga();
            c1 = SPI(0);
            c2 = SPI(0);
            SPI(0);
            SPI(0);
            SPI(0);
            SPI(0);
            DisableFpga();
        }
        while (!(c1 & CMD_RDTRK));

        if ((n & 15) == 0)
            printf("*");

        // send data sector to FPGA
        EnableFpga();
        c1 = SPI(0);
        c2 = SPI(0);
        SPI(0);
        SPI(0);
        SPI(0);
        SPI(0);
        p = sector_buffer;

        for (j = 0; j < 512; j++)
            SPI(*p++);

        DisableFpga();
    }
    printf("]\r");

    DEBUG_FUNC_OUT(DEBUG_F_FPGA | DEBUG_L0);
}
コード例 #2
0
ファイル: rafile.c プロジェクト: spersvold/minimig-de0_cv
int RARead(RAFile *file,unsigned char *pBuffer, unsigned long bytes)
{
    DEBUG_FUNC_IN(DEBUG_F_RAFILE | DEBUG_L2);

    int result=1;
    // Since we can only read from the SD card on 512-byte aligned boundaries,
    // we need to copy in multiple pieces.
    unsigned long blockoffset=file->ptr&511;    // Offset within the current 512 block at which the previous read finished
    // Bytes blockoffset to 512 will be drained first, before reading new data.

    if(blockoffset)     // If blockoffset is zero we'll just use aligned reads and don't need to drain the buffer.
    {
        int i;
        int l=bytes;
        if(l>512)
            l=512;
        for(i=blockoffset;i<l;++i)
        {
            *pBuffer++=file->buffer[i];
        }
        file->ptr+=l-blockoffset;
        bytes-=l-blockoffset;
    }

    // We've now read any bytes left over from a previous read.  If any data remains to be read we can read it
    // in 512-byte aligned chunks, until the last block.
    while(bytes>511)
    {
        result&=FileRead(&file->file,pBuffer);  // Read direct to pBuffer
        FileNextSector(&file->file);
        bytes-=512;
        file->ptr+=512;
        pBuffer+=512;
    }

    if(bytes)   // Do we have any bytes left to read?
    {
        unsigned int i;
        result&=FileRead(&file->file,file->buffer);     // Read to temporary buffer, allowing us to preserve any leftover for the next read.
        FileNextSector(&file->file);
        for(i=0;i<bytes;++i)
        {
            *pBuffer++=file->buffer[i];
        }
        file->ptr+=bytes;
    }
    return(result);

    DEBUG_FUNC_OUT(DEBUG_F_RAFILE | DEBUG_L2);
}
コード例 #3
0
ファイル: rafile.c プロジェクト: spersvold/minimig-de0_cv
int RAOpen(RAFile *file,const char *filename)
{
    DEBUG_FUNC_IN(DEBUG_F_RAFILE | DEBUG_L1);

    int result=1;
    if(!file)
        return(0);
    result=FileOpen(&file->file,filename);
    file->size=file->file.size;
    file->ptr=0;
    return(result);

    DEBUG_FUNC_OUT(DEBUG_F_RAFILE | DEBUG_L1);
}
コード例 #4
0
ファイル: main.c プロジェクト: amigabill/minimig-de1
// fatal error
void FatalError(void)
{
  DEBUG_FUNC_IN();

  DisableCard();

  // loop forever
  while(1) {
    TIMER_wait(200);
    LEDS(0x0);
    TIMER_wait(200);
    LEDS(led);
  }

  DEBUG_FUNC_OUT();
}
コード例 #5
0
ファイル: main.c プロジェクト: amigabill/minimig-de1
//// FatalError() ////
void FatalError(unsigned long error)
{
  DEBUG_FUNC_IN();

  sprintf(s,"Fatal error: %lu", error);
  BootPrintEx(s);
  printf(s);

  // loop forever
  while(1) {
    TIMER_wait(200);
    LEDS(0x0);
    TIMER_wait(200);
    LEDS(error);
  }

  DEBUG_FUNC_OUT();
}
コード例 #6
0
ファイル: main.c プロジェクト: jeffmilstea/minimig-de1
void main(void)
{
  DEBUG_FUNC_IN();

  fileTYPE ft;
  int i;

  // !!! a pointer to start of RAM
  unsigned char * ram = ((unsigned char *)0x400000);

  // initialize SD card
  LEDS(led=0xf);
  if (!MMC_Init()) FatalError();

  // find drive
  LEDS(led=0x8);
  if (!FindDrive()) FatalError();

  // open file
  LEDS(led=0x3);
  LoadFile(firmware,ram);
#if 0
  if (!FileOpen(&ft, firmware)) FatalError();

  // load firmware to RAM
  LEDS(led=0x1);
  for(i=0; i<((ft.size>>9)+1); i++) {
    FileRead(&ft, ram+(i*512));
    FileNextSector(&ft);
  }
#endif
  // jump to RAM firmware
  LEDS(led=0x0);
  DisableCard();
  sys_jump(0x400004);

  // loop forever
  while(1);

  DEBUG_FUNC_OUT();
}
コード例 #7
0
ファイル: rafile.c プロジェクト: spersvold/minimig-de0_cv
int RASeek(RAFile *file,unsigned long offset,unsigned long origin)
{
    DEBUG_FUNC_IN(DEBUG_F_RAFILE | DEBUG_L1);

    int result=1;
    unsigned long blockoffset;
    unsigned long blockaddress;
    if(origin==SEEK_CUR)
        offset+=file->ptr;
    blockoffset=offset&511;
    blockaddress=offset-blockoffset;    // 512-byte-aligned...
    result&=FileSeek(&file->file,blockaddress,SEEK_SET);
    if(result && blockoffset)   // If we're seeking into the middle of a block, we need to buffer it...
    {
        result&=FileRead(&file->file,file->buffer);
        FileNextSector(&file->file);
    }
    file->ptr=offset;
    return(result);

    DEBUG_FUNC_OUT(DEBUG_F_RAFILE | DEBUG_L1);
}
コード例 #8
0
ファイル: fpga.c プロジェクト: rkrajnc/minimig-de1
void SendFileEncrypted(RAFile *file,unsigned char *key,int keysize)
{
    DEBUG_FUNC_IN(DEBUG_F_FPGA | DEBUG_L0);

    unsigned char  c1, c2;
    unsigned char headersize;
    unsigned int keyidx=0;
    unsigned long  j;
    unsigned long  n;
    unsigned char *p;
    int badbyte=0;

    printf("[");
    headersize=file->size&255;	// ROM should be a round number of kilobytes; overspill will likely be the Amiga Forever header.

    RARead(file,sector_buffer,headersize);	// Read extra bytes

    n = (file->size + (511-headersize)) >> 9; // sector count (rounded up)
    while (n--)
    {
        RARead(file,sector_buffer,512);
        for (j = 0; j < 512; j++)
        {
            sector_buffer[j]^=key[keyidx++];
            if(keyidx>=(unsigned)keysize)
                keyidx-=keysize;
        }

        do
        {
            // read FPGA status
            EnableFpga();
            c1 = SPI(0);
            c2 = SPI(0);
            SPI(0);
            SPI(0);
            SPI(0);
            SPI(0);
            DisableFpga();
        }
        while (!(c1 & CMD_RDTRK));

        if ((n & 15) == 0)
            printf("*");

        // send data sector to FPGA
        EnableFpga();
        c1 = SPI(0);
        c2 = SPI(0);
        SPI(0);
        SPI(0);
        SPI(0);
        SPI(0);
        p = sector_buffer;

        for (j = 0; j < 512; j++)
            SPI(*p++);
        DisableFpga();
    }
    printf("]\r");

    DEBUG_FUNC_OUT(DEBUG_F_FPGA | DEBUG_L0);
}
コード例 #9
0
ファイル: main.c プロジェクト: amigabill/minimig-de1
__geta4 void main(void)
#endif
{
  DEBUG_FUNC_IN();

  uint32_t spiclk;
  fileTYPE sd_boot_file;

  HideSplash();
  SPI_fast();

  // boot message
  draw_boot_logo();
  BootPrintEx("**** MINIMIG-DE1 ****");
  BootPrintEx("Minimig by Dennis van Weeren");
  BootPrintEx("Updates by Jakub Bednarski, Tobias Gubener, Sascha Boing, A.M. Robinson & others");
  BootPrintEx("DE1 port by Rok Krajnc ([email protected])");
  BootPrintEx(" ");
  sprintf(s, "Build git commit: %s", __BUILD_REV);
  BootPrintEx(s);
  sprintf(s, "Build git tag: %s", __BUILD_TAG);
  BootPrintEx(s);
  BootPrintEx(" ");
  BootPrintEx("For updates & code see https://github.com/rkrajnc/minimig-de1");
  BootPrintEx("For support, see http://www.minimig.net");
  BootPrintEx(" ");

  printf("\r\r**** MINIMIG-DE1 ****\r\r");
  printf("Minimig by Dennis van Weeren\r");
  printf("Updates by Jakub Bednarski, Tobias Gubener, Sascha Boing, A.M. Robinson & others\r");
  printf("DE1 port by Rok Krajnc ([email protected])\r\r");
  printf("Build no. ");
  printf(__BUILD_NUM);
  //printf(" by ");
  //printf(__BUILD_USER);
  printf("\rgit commit ");
  printf(__BUILD_REV);
  printf("\rgit tag");
  printf(__BUILD_TAG);
  printf("\r\r");
  printf("For updates & code see https://github.com/rkrajnc/minimig-de1\r");
  printf("For support, see http://www.minimig.net/\r\r");

  spiclk = 100000 / (20*(read32(REG_SPI_DIV_ADR) + 2));
  printf("SPI divider: %u\r", read32(REG_SPI_DIV_ADR));
  sprintf(s, "SPI clock: %u.%uMHz", spiclk/100, spiclk%100);
  BootPrintEx(s);
  printf("%s\r", s);

  if (!MMC_Init()) FatalError(1);
  BootPrintEx("SD card found ...");
  printf("SD card found ...\r");

  if (!FindDrive()) FatalError(2);
  BootPrintEx("Drive found ...");
  printf("Drive found ...\r");

  ChangeDirectory(DIRECTORY_ROOT);

  //eject all disk
  df[0].status = 0;
  df[1].status = 0;
  df[2].status = 0;
  df[3].status = 0;
 
  BootPrintEx("Booting ...");
  printf("Booting ...\r");

  TIMER_wait(8000);
  config.kickstart.name[0]=0;
  SetConfigurationFilename(0); // Use default config
  LoadConfiguration(0);  // Use slot-based config filename

  // main loop
  while (1) {
    HandleFpga();
    HandleUI();
  }

  DEBUG_FUNC_OUT();
}