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
|
/*
* (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
*
* SPDX-License-Identifier: GPL-2.0
*/
#include "cmd_cpu.h"
//#include <ctype.h>
//#include <util/atomic.h>
#include "z80-if.h"
#include "con-utils.h"
//#include "env.h"
//#include "eval_arg.h"
//#include "getopt-min.h"
//#include "debug.h"
/* hack to get Z180 loadfile into flash memory */
#define const const FLASH
#include "../z180/cpuinfo.h"
#undef const
static const FLASH char * const FLASH cpu_strings[] = {
FSTR("Unknown CPU"),
FSTR("8080"),
FSTR("8085"),
FSTR("Z80"),
FSTR("x180"),
FSTR("HD64180"),
FSTR("Z80180"),
FSTR("Z80S180"),
};
command_ret_t do_cpuchk(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc UNUSED, char * const argv[] UNUSED)
{
uint8_t done = 0;
uint8_t cputype;
ERRNUM err = ESUCCESS;
uint8_t ram_save[cpuinfo_length];
if (z80_bus_state() & ZST_RUNNING) {
err = ERUNNING;
} else {
z80_bus_request_or_exit();
z80_read_block(ram_save, 0, cpuinfo_length);
z80_load_mem(0, cpuinfo,
&cpuinfo_sections,
cpuinfo_address,
cpuinfo_length_of_sections);
z80_bus_cmd(Release);
if (argv[1] && (argv[1][0] == 'n'))
goto donot;
z80_bus_cmd(Run);
clear_ctrlc(); /* forget any previous Control C */
while (done != 0xFF) {
_delay_ms(8);
/* check for ctrl-c to abort... */
if (had_ctrlc() || ctrlc()) {
err = EINTR;
break;
}
z80_bus_cmd(Request);
done = z80_read(3);
if (done == 0xFF)
cputype = z80_read(4);
z80_bus_cmd(Release);
}
z80_bus_cmd(Reset);
z80_bus_cmd(Request);
// z80_write_block(ram_save, 0, cpuinfo_length);
z80_bus_cmd(Release);
}
donot:
if (err)
cmd_error(CMD_RET_FAILURE, err, NULL);
if (done == 0xFF) {
if (cputype >= ARRAY_SIZE(cpu_strings))
cputype = 0;
printf_P(PSTR("Detected CPU: %S\n"), cpu_strings[cputype]);
}
return CMD_RET_SUCCESS;
}
|