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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [common/] [boot.c] - Blame information for rev 261

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 hellwig
/*
2
 * boot.c -- bootstrap from disk
3
 */
4
 
5
 
6
#include "common.h"
7
#include "stdarg.h"
8
#include "romlib.h"
9
#include "boot.h"
10
#include "cpu.h"
11
#include "mmu.h"
12
#include "start.h"
13
 
14
 
15 200 hellwig
void boot(int dskno, Bool start) {
16 59 hellwig
  Word capacity;
17
  Byte sig1, sig2;
18
 
19
  capacity = dskcap(dskno);
20
  if (capacity == 0) {
21
    printf("Disk not found!\n");
22
    return;
23
  }
24
  printf("Disk with 0x%08X sectors found, booting...\n", capacity);
25
  if (dskio(dskno, 'r', 0, PHYS_BOOT, 1) != 0) {
26
    printf("Disk error!\n");
27
    return;
28
  }
29
  sig1 = mmuReadByte(VIRT_BOOT + 512 - 2);
30
  sig2 = mmuReadByte(VIRT_BOOT + 512 - 1);
31
  if (sig1 != 0x55 || sig2 != 0xAA) {
32
    printf("MBR signature missing!\n");
33
    return;
34
  }
35
  /*
36
   * Boot convention:
37
   *   $16  disk number of boot disk
38
   *   $17  start sector number of disk or partition to boot
39
   *   $18  total number of sectors of disk or partition to boot
40
   */
41
  cpuSetReg(16, dskno);
42
  cpuSetReg(17, 0);
43
  cpuSetReg(18, capacity);
44
  cpuSetPC(VIRT_BOOT);
45 200 hellwig
  if (start) {
46
    cpuRun();
47
  }
48 59 hellwig
}

powered by: WebSVN 2.1.0

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