1 // SPDX-License-Identifier: MIT
3 #include "../pistorm-dev-enums.h"
4 #include "pistorm_dev.h"
6 #include <exec/resident.h>
7 #include <exec/errors.h>
8 #include <exec/memory.h>
9 #include <exec/lists.h>
10 #include <exec/alerts.h>
11 #include <exec/tasks.h>
13 #include <exec/execbase.h>
15 #include <libraries/expansion.h>
17 #include <devices/trackdisk.h>
18 #include <devices/timer.h>
19 #include <devices/scsidisk.h>
21 #include <dos/filehandler.h>
23 #include <proto/exec.h>
24 #include <proto/disk.h>
25 #include <proto/expansion.h>
31 #define LOADLIB(a, b) if ((a = (struct a*)OpenLibrary(b,0L))==NULL) { \
32 printf("Failed to load %s.\n", b); \
36 void print_usage(char *exe);
37 int get_command(char *cmd);
39 extern unsigned int pistorm_base_addr;
41 unsigned short cmd_arg = 0;
43 int __stdargs main (int argc, char *argv[]) {
49 int command = get_command(argv[1]);
51 printf("Unknown command %s.\n", argv[1]);
55 pistorm_base_addr = pi_find_pistorm();
57 if (pistorm_base_addr == 0xFFFFFFFF) {
58 printf ("Unable to find PiStorm autoconf device.\n");
62 printf ("PiStorm autoconf device found at $%.X\n", pistorm_base_addr);
65 unsigned int tmpvalue = 0;
66 unsigned short tmpshort = 0;
73 tmpshort = (unsigned short)atoi(argv[2]);
74 pi_reset_amiga(tmpshort);
77 printf ("PiStorm ----------------------------\n");
78 printf ("Hardware revision: %d.%d\n", (pi_get_hw_rev() >> 8), (pi_get_hw_rev() & 0xFF));
79 printf ("Software revision: %d.%d\n", (pi_get_sw_rev() >> 8), (pi_get_sw_rev() & 0xFF));
80 printf ("RTG: %s - %s\n", (pi_get_rtg_status() & 0x01) ? "Enabled" : "Disabled", (pi_get_rtg_status() & 0x02) ? "In use" : "Not in use");
81 printf ("NET: %s\n", pi_get_net_status() ? "Enabled" : "Disabled");
83 case PI_CMD_SWITCHCONFIG:
84 if (cmd_arg == PICFG_LOAD) {
86 printf ("User asked to load config, but no config filename specified.\n");
89 pi_handle_config(cmd_arg, argv[2]);
92 printf ("Unhandled command %s.\n", argv[1]);
100 int get_command(char *cmd) {
101 if (strcmp(cmd, "--restart") == 0 || strcmp(cmd, "--reboot") == 0 || strcmp(cmd, "--reset") == 0) {
104 if (strcmp(cmd, "--check") == 0 || strcmp(cmd, "--find") == 0 || strcmp(cmd, "--info") == 0) {
107 if (strcmp(cmd, "--config") == 0 || strcmp(cmd, "--config-file") == 0 || strcmp(cmd, "--cfg") == 0) {
108 cmd_arg = PICFG_LOAD;
109 return PI_CMD_SWITCHCONFIG;
115 void print_usage(char *exe) {
116 printf ("Usage: %s --[command] (arguments)\n", exe);
117 printf ("Example: %s --restart, --reboot or --reset\n", exe);
118 printf (" Restarts the Amiga.\n");
119 printf (" %s --check, --find or --info\n", exe);
120 printf (" Finds the PiStorm device and prints some data.\n");