forked from KolibriOS/kolibrios
Fixed get os version in SHELL
Signed-off-by: Maxim Logaev <maxlogaev@proton.me>
This commit is contained in:
parent
fa4755138f
commit
ec3af7f664
@ -759,6 +759,34 @@ KOSAPI void _ksys_shutdown(uint32_t shd_param)
|
|||||||
asm_inline("int $0x40" ::"a"(18), "b"(9), "c"(shd_param));
|
asm_inline("int $0x40" ::"a"(18), "b"(9), "c"(shd_param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*========= Function 18, subfunction 13 - get OS version. ========*/
|
||||||
|
|
||||||
|
#define KSYS_VER_HASH_LEN 9
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint8_t major;
|
||||||
|
uint8_t minor;
|
||||||
|
uint8_t patch;
|
||||||
|
uint8_t __reserved;
|
||||||
|
};
|
||||||
|
uint32_t value;
|
||||||
|
} tag;
|
||||||
|
uint16_t offset;
|
||||||
|
char hash[KSYS_VER_HASH_LEN + 1];
|
||||||
|
} ksys_os_ver_t;
|
||||||
|
|
||||||
|
KOSAPI int _ksys_get_os_ver(ksys_os_ver_t *ver)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
asm_inline(
|
||||||
|
"int $0x40"
|
||||||
|
: "=a"(status)
|
||||||
|
: "a"(18), "b"(13), "c"(ver));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/
|
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/
|
||||||
|
|
||||||
KOSAPI size_t _ksys_get_ram_size(void)
|
KOSAPI size_t _ksys_get_ram_size(void)
|
||||||
|
@ -6,16 +6,16 @@ void get_str_meminfo(char *str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cmd_kfetch(char param[]) {
|
int cmd_kfetch(char param[]) {
|
||||||
char *str_krnl_ver = malloc(64);
|
char str_krnl_ver[64];
|
||||||
get_str_kernel_version(str_krnl_ver, "%d.%d.%d.%d. SVN-rev.: %d");
|
get_str_kernel_version(str_krnl_ver, "v%d.%d.%d-%d-g%s");
|
||||||
char *str_uptime = malloc(64);
|
char str_uptime[64];
|
||||||
get_str_uptime(str_uptime, "%d day(s), %d:%d:%d.%d");
|
get_str_uptime(str_uptime, "%d day(s), %d:%d:%d.%d");
|
||||||
char *str_resolution = malloc(24);
|
char str_resolution[24];
|
||||||
ksys_pos_t resol = _ksys_screen_size();
|
ksys_pos_t resol = _ksys_screen_size();
|
||||||
sprintf(str_resolution, "%u x %u", resol.x + 1, resol.y + 1);
|
sprintf(str_resolution, "%u x %u", resol.x + 1, resol.y + 1);
|
||||||
char *str_cpu_info = malloc(16);
|
char str_cpu_info[16];
|
||||||
get_str_cpu_info(str_cpu_info);
|
get_str_cpu_info(str_cpu_info);
|
||||||
char *str_meminfo = malloc(24);
|
char str_meminfo[24];
|
||||||
get_str_meminfo(str_meminfo);
|
get_str_meminfo(str_meminfo);
|
||||||
|
|
||||||
printf(/*"\033[0;34;40m \033[0m\n\r"*/
|
printf(/*"\033[0;34;40m \033[0m\n\r"*/
|
||||||
@ -42,12 +42,7 @@ int cmd_kfetch(char param[]) {
|
|||||||
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m.\033[0;1;30;40m8\033[0;5;37;45m@\033[0;5;35;44m:\033[0;1;30;45m8\033[0;5;34;44m \033[0;5;35;45m \033[0;1;34;44m8\033[0;1;35;45m.\033[0;5;34;40mX\033[0;34;40m@\033[0;32;40mS\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m.\033[0;1;30;40m8\033[0;5;37;45m@\033[0;5;35;44m:\033[0;1;30;45m8\033[0;5;34;44m \033[0;5;35;45m \033[0;1;34;44m8\033[0;1;35;45m.\033[0;5;34;40mX\033[0;34;40m@\033[0;32;40mS\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m \033[0;34;40m.;\033[0;1;30;40m8\033[0;1;30;44m8\033[0;34;40m8\033[0;5;34;40m8\033[0;32;40m%%\033[0;34;40m8;\033[0;32;40m;\033[0;31;40m.\033[0;32;40m \033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m \033[0;34;40m.;\033[0;1;30;40m8\033[0;1;30;44m8\033[0;34;40m8\033[0;5;34;40m8\033[0;32;40m%%\033[0;34;40m8;\033[0;32;40m;\033[0;31;40m.\033[0;32;40m \033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;32;40m .\033[0;31;40m .:\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0m\n\r",
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;32;40m .\033[0;31;40m .:\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0m\n\r",
|
||||||
"\033[0;36mOS\033[0m: KolibriOS", "\033[0;36mKernel\033[0m: ", str_krnl_ver, "\033[0;36mUptime\033[0m: ", str_uptime, "\033[0;36mResolution\033[0m: ", str_resolution, "\033[0;36mCPU\033[0m: ", str_cpu_info, "\033[0;36mMemory\033[0m: ", str_meminfo);
|
"\033[0;36mOS\033[0m: KolibriOS", "\033[0;36mVersion\033[0m: ", str_krnl_ver, "\033[0;36mUptime\033[0m: ", str_uptime, "\033[0;36mResolution\033[0m: ", str_resolution, "\033[0;36mCPU\033[0m: ", str_cpu_info, "\033[0;36mMemory\033[0m: ", str_meminfo);
|
||||||
|
|
||||||
free(str_krnl_ver);
|
|
||||||
free(str_uptime);
|
|
||||||
free(str_resolution);
|
|
||||||
free(str_cpu_info);
|
|
||||||
free(str_meminfo);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
@ -1,52 +1,42 @@
|
|||||||
|
|
||||||
void get_str_kernel_version(char *str, const char *fmt) {
|
void get_str_kernel_version(char *str, const char *fmt) {
|
||||||
char *kvbuf;
|
ksys_os_ver_t ver;
|
||||||
char *vA, *vB, *vC, *vD;
|
_ksys_get_os_ver(&ver);
|
||||||
unsigned *Rev;
|
sprintf(str, fmt, ver.tag.major, ver.tag.minor, ver.tag.patch, ver.offset, ver.hash);
|
||||||
|
|
||||||
kvbuf = malloc(16);
|
|
||||||
kol_get_kernel_ver(kvbuf);
|
|
||||||
vA = kvbuf+0;
|
|
||||||
vB = kvbuf+1;
|
|
||||||
vC = kvbuf+2;
|
|
||||||
vD = kvbuf+3;
|
|
||||||
Rev = (unsigned*)(kvbuf + 5);
|
|
||||||
|
|
||||||
sprintf (str, fmt, *vA, *vB, *vC, *vD, *Rev);
|
|
||||||
|
|
||||||
free(kvbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_str_cpu_info(char *str) {
|
void get_str_cpu_info(char *str) {
|
||||||
unsigned a, b, c, d;
|
unsigned a, b, c, d;
|
||||||
|
|
||||||
asm ("cpuid" :
|
__asm__ __volatile__(
|
||||||
"=a" (a),
|
"cpuid"
|
||||||
|
:"=a" (a),
|
||||||
"=b" (b),
|
"=b" (b),
|
||||||
"=c" (c),
|
"=c" (c),
|
||||||
"=d" (d):
|
"=d" (d):
|
||||||
"a"(0));
|
"a"(0)
|
||||||
|
);
|
||||||
|
|
||||||
str[0] = (b&0x000000ff) >> 0;
|
str[0] = (b & 0x000000ff) >> 0;
|
||||||
str[1] = (b&0x0000ff00) >> 8;
|
str[1] = (b & 0x0000ff00) >> 8;
|
||||||
str[2] = (b&0x00ff0000) >> 16;
|
str[2] = (b & 0x00ff0000) >> 16;
|
||||||
str[3] = (b&0xff000000) >> 24;
|
str[3] = (b & 0xff000000) >> 24;
|
||||||
|
|
||||||
str[4] = (d&0x000000ff) >> 0;
|
str[4] = (d & 0x000000ff) >> 0;
|
||||||
str[5] = (d&0x0000ff00) >> 8;
|
str[5] = (d & 0x0000ff00) >> 8;
|
||||||
str[6] = (d&0x00ff0000) >> 16;
|
str[6] = (d & 0x00ff0000) >> 16;
|
||||||
str[7] = (d&0xff000000) >> 24;
|
str[7] = (d & 0xff000000) >> 24;
|
||||||
|
|
||||||
str[8] = (c&0x000000ff) >> 0;
|
str[8] = (c & 0x000000ff) >> 0;
|
||||||
str[9] = (c&0x0000ff00) >> 8;
|
str[9] = (c & 0x0000ff00) >> 8;
|
||||||
str[10] = (c&0x00ff0000) >> 16;
|
str[10] = (c & 0x00ff0000) >> 16;
|
||||||
str[11] = (c&0xff000000) >> 24;
|
str[11] = (c & 0xff000000) >> 24;
|
||||||
str[12] = '\0';
|
str[12] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_ver(char param[]) {
|
int cmd_ver(char param[]) {
|
||||||
if (!strcmp(param, "kernel")) {
|
if (!strcmp(param, "kernel")) {
|
||||||
get_str_kernel_version(tmpstr, CMD_VER_FMT1);
|
get_str_kernel_version(tmpstr, " KolibriOS v%d.%d.%d-%d-g%s\n\r");
|
||||||
printf(tmpstr);
|
printf(tmpstr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -61,4 +51,3 @@ int cmd_ver(char param[]) {
|
|||||||
printf (" Shell v%s\n\r", SHELL_VERSION);
|
printf (" Shell v%s\n\r", SHELL_VERSION);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ const command_t COMMANDS[]=
|
|||||||
#define CMD_SLEEP_USAGE " sleep <time in the 1/100 of second>\n\r"
|
#define CMD_SLEEP_USAGE " sleep <time in the 1/100 of second>\n\r"
|
||||||
#define CMD_TOUCH_USAGE " touch <filename>\n\r"
|
#define CMD_TOUCH_USAGE " touch <filename>\n\r"
|
||||||
#define CMD_UPTIME_FMT " Uptime: %d day(s), %d:%d:%d.%d\n\r"
|
#define CMD_UPTIME_FMT " Uptime: %d day(s), %d:%d:%d.%d\n\r"
|
||||||
#define CMD_VER_FMT1 " KolibriOS v%d.%d.%d.%d. Kernel SVN-rev.: %d\n\r"
|
|
||||||
#define CMD_WAITFOR_FMT " Awaing finish PID %d\n\r"
|
#define CMD_WAITFOR_FMT " Awaing finish PID %d\n\r"
|
||||||
#define EXEC_STARTED_FMT " '%s' started. PID = %d\n\r"
|
#define EXEC_STARTED_FMT " '%s' started. PID = %d\n\r"
|
||||||
#define EXEC_SCRIPT_ERROR_FMT "Error in '%s' : script must start with #SHS line\n\r"
|
#define EXEC_SCRIPT_ERROR_FMT "Error in '%s' : script must start with #SHS line\n\r"
|
||||||
|
@ -59,7 +59,6 @@ const command_t COMMANDS[]=
|
|||||||
#define CMD_SLEEP_USAGE " sleep <¨â¥à¢ « ¢ á®âëå ¤®«ïx ᥪã¤ë>\n\r"
|
#define CMD_SLEEP_USAGE " sleep <¨â¥à¢ « ¢ á®âëå ¤®«ïx ᥪã¤ë>\n\r"
|
||||||
#define CMD_TOUCH_USAGE " touch <¨¬ï ä ©« >\n\r"
|
#define CMD_TOUCH_USAGE " touch <¨¬ï ä ©« >\n\r"
|
||||||
#define CMD_UPTIME_FMT " Uptime: %d ¤¥©, %d:%d:%d.%d\n\r"
|
#define CMD_UPTIME_FMT " Uptime: %d ¤¥©, %d:%d:%d.%d\n\r"
|
||||||
#define CMD_VER_FMT1 " KolibriOS v%d.%d.%d.%d. SVN-ॢ. ï¤à : %d\n\r"
|
|
||||||
#define CMD_WAITFOR_FMT " Ž¦¨¤ ¥¬ § ¢¥à襨ï PID %d\n\r"
|
#define CMD_WAITFOR_FMT " Ž¦¨¤ ¥¬ § ¢¥à襨ï PID %d\n\r"
|
||||||
#define EXEC_STARTED_FMT " '%s' § ¯ãé¥. PID = %d\n\r"
|
#define EXEC_STARTED_FMT " '%s' § ¯ãé¥. PID = %d\n\r"
|
||||||
#define EXEC_SCRIPT_ERROR_FMT "Žè¨¡ª ¢ '%s' : áªà¨¯â ¤®«¦¥ ç¨ âìáï á® áâà®çª¨ #SHS\n\r"
|
#define EXEC_SCRIPT_ERROR_FMT "Žè¨¡ª ¢ '%s' : áªà¨¯â ¤®«¦¥ ç¨ âìáï á® áâà®çª¨ #SHS\n\r"
|
||||||
|
Loading…
Reference in New Issue
Block a user