1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* Misc boot support
*/
#include "common.h"
#include <stdlib.h>
#include <avr/pgmspace.h>
#include "command.h"
#include "z80-if.h"
/* ugly hack to get Z180 loadfile into flash memory */
#define const const FLASH
#include "../z180/hdrom.h"
#undef const
static void z80_load_mem(void)
{
unsigned sec = 0;
uint32_t sec_base = hdrom_start;
printf_P(PSTR("Loading Z180 memory... \n"));
while (sec < hdrom_sections) {
printf_P(PSTR(" From: 0x%.5lX to: 0x%.5lX (%5li bytes)\n"),
hdrom_address[sec],
hdrom_address[sec]+hdrom_length_of_sections[sec] - 1,
hdrom_length_of_sections[sec]);
z80_request_bus();
z80_write_block((const FLASH unsigned char *) &hdrom[sec_base], /* src */
hdrom_address[sec], /* dest */
hdrom_length_of_sections[sec]); /* len */
z80_release_bus();
sec_base+=hdrom_length_of_sections[sec];
sec++;
}
}
int do_loadf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
(void) cmdtp; (void) flag; (void) argc; (void) argv;
if (z80_runstate() != 0) {
printf_P(PSTR("## Can't load while CPU is running!\n"));
return 1;
}
z80_load_mem();
return 0;
}
int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint32_t addr;
(void) cmdtp; (void) flag; (void) argc;
if (z80_runstate() != 0) {
printf_P(PSTR("## CPU allready running!\n"));
return 1;
}
addr = strtoul(argv[1], NULL, 16);
if (addr > (1UL<<16) - 1) {
printf_P(PSTR("## Startaddress 0x%05lx too high.\n"
" (Out of logical address space (0x00000-0x0ffff))\n"),
addr);
return 1;
} else if (addr != 0) {
printf_P(PSTR("## Starting application at "
"address != 0x0000 not implemented yet.\n"));
return 1;
} else {
printf_P(PSTR("## Starting application at 0x%05lX ...\n"), addr);
z80_release_bus();
z80_reset(HIGH);
}
return 0;
}
int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
(void) cmdtp; (void) flag; (void) argc; (void) argv;
printf_P(PSTR("## CPU now in reset state.\n"));
z80_reset(LOW);
return 0;
}
int do_restart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
(void) cmdtp; (void) flag; (void) argc; (void) argv;
z80_reset_pulse();
return 0;
}
|