-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmds: implement
device
driver enumeration tool
JIRA: RTOS-848
- Loading branch information
Showing
15 changed files
with
132 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* Operating system loader | ||
* | ||
* List device drivers | ||
* | ||
* Copyright 2024 Phoenix Systems | ||
* Author: Gerard Swiderski | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
|
||
#include <devices/devs.h> | ||
|
||
#include "cmd.h" | ||
|
||
#define DEVS_HEADER_FORMAT "%5s %5s %-10s %s" | ||
#define DEVS_ENTRY_FORMAT "%5u %5u %-10s %s" | ||
|
||
|
||
static void cmd_devsInfo(void) | ||
{ | ||
lib_printf("enumerates registered device drivers"); | ||
} | ||
|
||
|
||
static const char *devClassName(unsigned int major) | ||
{ | ||
static const char *className[] = { | ||
"uart", "usb", "storage", "tty", "ram", "nand-data", "nand-meta", "nand-raw", "pipe" | ||
}; | ||
|
||
return (major < (sizeof(className) / sizeof(className[0]))) ? | ||
className[major] : | ||
"unknown"; | ||
} | ||
|
||
|
||
static int cmd_devs(int argc, char *argv[]) | ||
{ | ||
unsigned int ctx = 0; | ||
unsigned int major = 0; | ||
unsigned int minor = 0; | ||
|
||
if (argc != 1) { | ||
log_error("\n%s: Wrong argument count", argv[0]); | ||
return CMD_EXIT_FAILURE; | ||
} | ||
|
||
lib_printf("\n\033[1m" DEVS_HEADER_FORMAT "\033[0m\n", "MAJOR", "MINOR", "CLASS", "DRIVER NAME"); | ||
|
||
for (;;) { | ||
const dev_t *dev = devs_iterNext(&ctx, &major, &minor); | ||
if (dev == DEVS_ITER_STOP) { | ||
break; | ||
} | ||
|
||
if (dev != NULL) { | ||
lib_printf(DEVS_ENTRY_FORMAT "\n", major, minor, devClassName(major), dev->name); | ||
} | ||
} | ||
|
||
return CMD_EXIT_SUCCESS; | ||
} | ||
|
||
|
||
static const cmd_t devices_cmd __attribute__((section("commands"), used)) = { | ||
.name = "devices", .run = cmd_devs, .info = cmd_devsInfo | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters