]>
cloudbase.mooo.com Git - z180-stamp.git/blob - avr/cmd_boot.c
1699a5c7e9c51b0b233f2277e44eec2f68e55a59
7 #include <util/delay.h>
8 #include <avr/pgmspace.h>
13 /* ugly hack to get Z180 loadfile into flash memory */
14 #define const const FLASH
15 #include "../z180/hdrom.h"
20 static void z80_load_mem(void)
23 uint32_t sec_base
= hdrom_start
;
25 printf_P(PSTR("Loading Z180 memory... \n"));
27 while (sec
< hdrom_sections
) {
28 printf_P(PSTR(" From: 0x%.5lX to: 0x%.5lX (%5li bytes)\n"),
30 hdrom_address
[sec
]+hdrom_length_of_sections
[sec
] - 1,
31 hdrom_length_of_sections
[sec
]);
34 z80_write_block((const FLASH
unsigned char *) &hdrom
[sec_base
], /* src */
35 hdrom_address
[sec
], /* dest */
36 hdrom_length_of_sections
[sec
]); /* len */
38 sec_base
+=hdrom_length_of_sections
[sec
];
43 int do_loadf(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
45 (void) cmdtp
; (void) flag
; (void) argc
; (void) argv
;
47 if (z80_bus_state() & ZST_RUNNING
) {
48 printf_P(PSTR("## Can't load while CPU is running!\n"));
58 int do_busreq_pulse(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
62 (void) cmdtp
; (void) flag
;
64 if (!(z80_bus_state() & ZST_RUNNING
)) {
65 printf_P(PSTR("## CPU is not running!\n"));
70 count
= (uint16_t) strtoul(argv
[2], NULL
, 16);
80 int do_go(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
84 (void) cmdtp
; (void) flag
;
88 addr
= strtoul(argv
[1], NULL
, 16);
89 if (addr
>= (1UL<<16)) {
90 printf_P(PSTR("## Startaddress 0x%05lx too high.\n"
91 " (Out of logical address space (0x00000-0x0ffff))\n"),
96 if (z80_bus_state() & ZST_RUNNING
) {
97 printf_P(PSTR("## CPU allready running!\n"));
101 printf_P(PSTR("## Starting application at 0x%04lx ...\n"), addr
);
107 z80_bus_cmd(Request
);
108 for (i
= 0; i
< 3; i
++)
109 tmp
[i
] = z80_read(i
);
112 z80_write(2, (addr
>> 8));
115 z80_bus_cmd(M_Cycle
);
116 z80_bus_cmd(M_Cycle
);
117 for (i
= 0; i
< 3; i
++)
118 z80_write(i
, tmp
[i
]);
122 z80_bus_cmd(Release
);
127 int do_reset(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
129 (void) cmdtp
; (void) flag
; (void) argc
; (void) argv
;
131 printf_P(PSTR("## CPU now in reset state.\n"));
137 int do_restart(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
139 (void) cmdtp
; (void) flag
; (void) argc
; (void) argv
;
141 z80_bus_cmd(Restart
);