OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [common/] [boot.c] - Diff between revs 88 and 200

Only display areas with differences | Details | Blame | View Log

Rev 88 Rev 200
/*
/*
 * boot.c -- bootstrap from disk
 * boot.c -- bootstrap from disk
 */
 */
 
 
 
 
#include "common.h"
#include "common.h"
#include "stdarg.h"
#include "stdarg.h"
#include "romlib.h"
#include "romlib.h"
#include "boot.h"
#include "boot.h"
#include "cpu.h"
#include "cpu.h"
#include "mmu.h"
#include "mmu.h"
#include "start.h"
#include "start.h"
 
 
 
 
void boot(int dskno) {
void boot(int dskno, Bool start) {
  Word capacity;
  Word capacity;
  Byte sig1, sig2;
  Byte sig1, sig2;
 
 
  capacity = dskcap(dskno);
  capacity = dskcap(dskno);
  if (capacity == 0) {
  if (capacity == 0) {
    printf("Disk not found!\n");
    printf("Disk not found!\n");
    return;
    return;
  }
  }
  printf("Disk with 0x%08X sectors found, booting...\n", capacity);
  printf("Disk with 0x%08X sectors found, booting...\n", capacity);
  if (dskio(dskno, 'r', 0, PHYS_BOOT, 1) != 0) {
  if (dskio(dskno, 'r', 0, PHYS_BOOT, 1) != 0) {
    printf("Disk error!\n");
    printf("Disk error!\n");
    return;
    return;
  }
  }
  sig1 = mmuReadByte(VIRT_BOOT + 512 - 2);
  sig1 = mmuReadByte(VIRT_BOOT + 512 - 2);
  sig2 = mmuReadByte(VIRT_BOOT + 512 - 1);
  sig2 = mmuReadByte(VIRT_BOOT + 512 - 1);
  if (sig1 != 0x55 || sig2 != 0xAA) {
  if (sig1 != 0x55 || sig2 != 0xAA) {
    printf("MBR signature missing!\n");
    printf("MBR signature missing!\n");
    return;
    return;
  }
  }
  /*
  /*
   * Boot convention:
   * Boot convention:
   *   $16  disk number of boot disk
   *   $16  disk number of boot disk
   *   $17  start sector number of disk or partition to boot
   *   $17  start sector number of disk or partition to boot
   *   $18  total number of sectors of disk or partition to boot
   *   $18  total number of sectors of disk or partition to boot
   */
   */
  cpuSetReg(16, dskno);
  cpuSetReg(16, dskno);
  cpuSetReg(17, 0);
  cpuSetReg(17, 0);
  cpuSetReg(18, capacity);
  cpuSetReg(18, capacity);
  cpuSetPC(VIRT_BOOT);
  cpuSetPC(VIRT_BOOT);
 
  if (start) {
  cpuRun();
  cpuRun();
}
}
 
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.