WIP: Changing the OS version retrieval API due to migration to Git #62

Draft
mxlgv wants to merge 2 commits from change-get-version-api into main
14 changed files with 132 additions and 126 deletions

View File

@ -872,8 +872,8 @@ for i,v in ipairs(img_files) do
-- note that .revision and .kernel.mnt must begin with .
-- to prevent tup from tracking them
if build_type == "rus"
then str='$(LANG=ru_RU.utf8 date -u +"[автосборка %d %b %Y %R, r$(get-current-revision)]"|iconv -f utf8 -t cp866)'
else str='$(date -u +"[auto-build %d %b %Y %R, r$(get-current-revision)]")'
then str='$(LANG=ru_RU.utf8 date -u +"[автосборка %d %b %Y %R, g$(git rev-parse --short HEAD)]"|iconv -f utf8 -t cp866)'
else str='$(date -u +"[autobuild %d %b %Y %R, g$(git rev-parse --short HEAD)]")'
Review

We are having a hard time switching from svn to git now. This is partially because of svn features that git lacks, e.g. svn-keywords. Maybe we shouldn't repeat our mistakes and hardcode git specific commands now. If get-current-revision is an external command to get an svn revision number, let's use something like get-current-commit-hash for git. Or, even better, get-current-commit-id. The last one looks even more VCS-neutral, i.e. future-proof.

We are having a hard time switching from svn to git now. This is partially because of svn features that git lacks, e.g. svn-keywords. Maybe we shouldn't repeat our mistakes and hardcode git specific commands now. If get-current-revision is an external command to get an svn revision number, let's use something like get-current-commit-hash for git. Or, even better, get-current-commit-id. The last one looks even more VCS-neutral, i.e. future-proof.
end
str = string.gsub(str, "%$", "\\$") -- escape $ as \$
str = string.gsub(str, "%%", "%%%%") -- escape % as %%
@ -899,7 +899,7 @@ end
-- generate tup rule for kolibri.iso
if tup.getconfig("INSERT_REVISION_ID") ~= ""
then volume_id = "KolibriOS r`get-current-revision`"
then volume_id = "KolibriOS g`git rev-parse --short HEAD`"
else volume_id = "KolibriOS"
end
tup.definerule{inputs = input_deps, command =

View File

@ -1,8 +1,9 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en" or tup.getconfig("LANG")) .. " > %o", {"lang.inc"})
tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 262144 %f %o " .. tup.getconfig("KERPACK_CMD"), "kernel.mnt")
tup.rule("./version-gen.sh", {extra_outputs={"ver.inc", "ver_boot.inc"}})
tup.rule({"kernel.asm", extra_inputs = {"lang.inc", "ver.inc", "ver_boot.inc"}}, "fasm -m 262144 %f %o " .. tup.getconfig("KERPACK_CMD"), "kernel.mnt")
--tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 262144 %f %o -s %o.fas" .. tup.getconfig("KERPACK_CMD"), {"kernel.mnt", extra_outputs = {"kernel.mnt.fas"}})
--tup.rule({"kernel.mnt.fas", extra_inputs = {"kernel.mnt"}}, "symbols %f %o", "kernel.mnt.sym")
--tup.rule({"kernel.mnt.fas", extra_inputs = {"kernel.mnt"}}, "listing %f %o", "kernel.mnt.lst")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 262144 %f %o -dextended_primary_loader=1" .. tup.getconfig("KERPACK_CMD"), "kernel.mnt.ext_loader")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc"}}, "fasm -m 262144 %f %o -dpretest_build=1 -ddebug_com_base=0xe9", "kernel.mnt.pretest")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc", "ver.inc", "ver_boot.inc"}}, "fasm -m 262144 %f %o -dextended_primary_loader=1" .. tup.getconfig("KERPACK_CMD"), "kernel.mnt.ext_loader")
tup.rule({"kernel.asm", extra_inputs = {"lang.inc", "ver.inc", "ver_boot.inc"}}, "fasm -m 262144 %f %o -dpretest_build=1 -ddebug_com_base=0xe9", "kernel.mnt.pretest")

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -31,18 +31,6 @@ macro line_space {
}
d80x25_top:
line_full_top
if __REV__ > 0
cur_line_pos = 75
store byte ' ' at d80x25_top+cur_line_pos+1
rev_var = __REV__
while rev_var > 0
store byte rev_var mod 10 + '0' at d80x25_top+cur_line_pos
cur_line_pos = cur_line_pos - 1
rev_var = rev_var / 10
end while
store byte ' ' at d80x25_top+cur_line_pos
store dword ' SVN' at d80x25_top+cur_line_pos-4
end if
space_msg:
line_space

View File

@ -24,7 +24,7 @@ org 0
; struct kernel_header
jmp start_of_code ; jump
db 'KolibriOS ' ; signature
db 'v0.7.7.0+ ',13,10,13,10,0 ; version
include "ver_boot.inc" ; version
dd B32-KERNEL_BASE ; offset of the kernel's 32-bit entry point
include "boot/bootstr.inc" ; language-independent boot messages

View File

@ -1,11 +1,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.7.0
СИСТЕМНЫЕ ФУНКЦИИ KolibriOS 0.7.7-0+
Номер функции помещается в регистр eax.
Вызов системной функции осуществляется командой "int 0x40".
@ -952,7 +952,7 @@ picture rb Xsize*Ysize*4 ; 32 бита
eax - SF_SYSTEM (18)
ebx - SSF_INFO_DISC_SYS (11)
======================================================================
========== Функция 18, подфункция 13 - получить версию ядра. =========
========== Функция 18, подфункция 13 - получить версию ОС. ===========
======================================================================
Параметры:
* eax = 18 - номер функции
@ -962,25 +962,22 @@ picture rb Xsize*Ysize*4 ; 32 бита
Возвращаемое значение:
* функция не возвращает значения
но, если указатель в ecx недопустимый, например,
регион [ecx, ecx + 9) пересекается с памятью ядра,
регион [ecx, ecx + 16) пересекается с памятью ядра,
то тогда функция возвращает -1
Замечания:
* В данный момент используется только часть буфера размером
9 байт. Тем не менее рекомендуется использовать буфер
размером 16 байт для будущей совместимости, в будущем могут быть
добавлены некоторые поля.
Структура буфера:
db a,b,c,d для версии a.b.c.d
db 0: зарезервировано
dd REV - номер svn-ревизии ядра
Для ядра Kolibri 0.7.7.0+:
db 0,7,7,0
db major, minor, patch - git-тег
db 0 - зарезервировано для выравнивания git-тега до dword;
dw offset - количество коммитов от git-тега;
db 'hash', 0 - нуль-терминированная строка git-хэша.
Например для KolibriOS v0.7.7-8672-g99ffedbae:
db 0,7,7
db 0
dd 1675
dw 8672
db '99ffedbae', 0
---------------------- Константы для регистров: ----------------------
eax - SF_SYSTEM (18)
ebx - SSF_KERNEL_VERSION (13)
ebx - SSF_KERNEL_VERSION/SSF_OS_VERSION (13)
======================================================================
====================== Функция 18, подфункция 14 =====================
======= Ожидать начала обратного хода луча развёртки монитора. =======

View File

@ -1,11 +1,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SYSTEM FUNCTIONS of OS Kolibri 0.7.7.0
SYSTEM FUNCTIONS of KolibriOS 0.7.7-0+
Number of the function is located in the register eax.
The call of the system function is executed by "int 0x40" command.
@ -944,7 +944,7 @@ Remarks:
eax - SF_SYSTEM (18)
ebx - SSF_INFO_DISC_SYS (11)
======================================================================
========== Function 18, subfunction 13 - get kernel version. =========
========== Function 18, subfunction 13 - get OS version. =============
======================================================================
Parameters:
* eax = 18 - function number
@ -954,25 +954,22 @@ Parameters:
Returned value:
* function does not return value
but if pointer in ecx is illegal, for example,
[ecx, ecx + 9) region intersects with kernel memory,
[ecx, ecx + 16) region intersects with kernel memory,
then function returns -1
Remarks:
* At the moment only the part of the buffer by a size
9 bytes is used. Nevertheless it is recommended to use
16 byte buffer for the future compatibility, in the future
some fields can be added.
Structure of the buffer:
db a,b,c,d for version a.b.c.d
db 0: reserved
dd REV - kernel SVN revision number
For Kolibri 0.7.7.0+ kernel:
db 0,7,7,0
db major, minor, patch - git-tag;
db 0 - reserved for alignment to dword;
dw offset - number of commits after git-tag;
Review

Do we need that offset at all? I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'. My opinion is that we should care more about readability rather than revision numbers. Because the number of revisions is unlimited unlike the number of developers and amount of their time. Maybe switching to git is a great moment to drop revision numbers and all kinds of commit counters completely and use just hashes and release tags.

Do we need that offset at all? I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'. My opinion is that we should care more about readability rather than revision numbers. Because the number of revisions is unlimited unlike the number of developers and amount of their time. Maybe switching to git is a great moment to drop revision numbers and all kinds of commit counters completely and use just hashes and release tags.
Review

Do we need that offset at all?

Yes. We're planning 2 image variants: release (versioned) and night build, where offset will show how far this image from release

I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'.

'Cuz for people revision number is not just number, but almost version. Why to increment version if you just fix TYPO?
Also, as I understood, SVN can't push multiple commits. So, why not to put some minor changes in one commit?

My opinion is that we should care more about readability rather than revision numbers.

v0.7.7.6+12 is pretty readable, isn't?

Because the number of revisions is unlimited unlike the number of developers and amount of their time.

Wdym? This structure should be initialized while building by script

Maybe switching to git is a great moment to drop revision numbers

We do

and all kinds of commit counters completely and use just hashes and release tags.

  • Release tags for versions
  • Hashes for precise identification of a commit and searching
  • Offsets for night versions
> Do we need that offset at all? Yes. We're planning 2 image variants: release (versioned) and night build, where offset will show how far this image from release > I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'. 'Cuz for people revision number is not just number, but almost version. Why to increment version if you just fix TYPO? Also, as I understood, SVN can't push multiple commits. So, why not to put some minor changes in one commit? > My opinion is that we should care more about readability rather than revision numbers. `v0.7.7.6+12` is pretty readable, isn't? > Because the number of revisions is unlimited unlike the number of developers and amount of their time. Wdym? This structure should be initialized while building by script > Maybe switching to git is a great moment to drop revision numbers We do > and all kinds of commit counters completely and use just hashes and release tags. - Release tags for versions - Hashes for precise identification of a commit and searching - Offsets for night versions
Review

Do we need that offset at all?

Yes. We're planning 2 image variants: release (versioned) and night build, where offset will show how far this image from release

Why would we want to know 'how far this image from release'? This info is of no use. Let's say an image is 20, 200 or 2000 commits from a git tag, so what? I believe the next release should happen when all the roadmap tickets are closed. Are we going to have a roadmap ticket like 'make 100 commits'?

I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'.

'Cuz for people revision number is not just number, but almost version.

Then maybe people should spend more time reading manuals. Because revision numbers of a repo are not distro versions at all. For example, there are quite a few files in our repo that are not in the distro. Changing many of them doesn't even trigger the autobuild. When it comes to technical matters, reading manuals really helps.

Why to increment version if you just fix TYPO?

I didn't say that.

Also, as I understood, SVN can't push multiple commits. So, why not to put some minor changes in one commit?

First of all, it takes time for other people to find out that the changes are actually unrelated. It is obvious for the author but not for others. Then, merging unrelated changes into one commit makes it harder to understand and review them. One commit of 10 files is harder to understand than 10 trivial commits. Sometimes 10 changes are spread over 3 files where each file has about 3 unrelated edits. Enjoy your time reading and reviewing. If a developer is lazy to commit unrelated changes separately, then why should other people spend their time on sorting things out and review? You are lazy and we are lasy, high five, tl;dr.

My opinion is that we should care more about readability rather than revision numbers.

v0.7.7.6+12 is pretty readable, isn't?

I meant readability of patches. By saving a few revision numbers a developer wastes time of other developers. So, what is a more important resource to save: revision numbers or developer time?

If we can keep it as short and readable as v0.7.7.6+, what is the reason to make it longer and less readable?

Because the number of revisions is unlimited unlike the number of developers and amount of their time.

Wdym? This structure should be initialized while building by script

I mean the same thing as I described above. Ten trivial commits are easier to understand than a single commit of ten files, because firstly you have to somehow find out the changes are unrelated. It takes time of developers. The larger a commit is, the less a developer wants to review it. For example, I don't see many people reviewing this PR, even though they have been asking for git for years. Partially because the kernel commit addresses several issues at once and nobody wants to bother with it.

Maybe switching to git is a great moment to drop revision numbers

We do

and all kinds of commit counters completely and use just hashes and release tags.

  • Release tags for versions
  • Hashes for precise identification of a commit and searching
  • Offsets for night versions

Why can't we use hashes for nightbuilds too? Why to introduce yet another entity of a tag offset?

> > Do we need that offset at all? > > Yes. We're planning 2 image variants: release (versioned) and night build, where offset will show how far this image from release Why would we want to know 'how far this image from release'? This info is of no use. Let's say an image is 20, 200 or 2000 commits from a git tag, so what? I believe the next release should happen when all the roadmap tickets are closed. Are we going to have a roadmap ticket like 'make 100 commits'? > > I have noticed that some people prefer to put unrelated changes to a single commit 'not to waste revision numbers'. > > 'Cuz for people revision number is not just number, but almost version. Then maybe people should spend more time reading manuals. Because revision numbers of a repo are not distro versions at all. For example, there are quite a few files in our repo that are not in the distro. Changing many of them doesn't even trigger the autobuild. When it comes to technical matters, reading manuals really helps. > Why to increment version if you just fix TYPO? I didn't say that. > Also, as I understood, SVN can't push multiple commits. So, why not to put some minor changes in one commit? First of all, it takes time for other people to find out that the changes are actually unrelated. It is obvious for the author but not for others. Then, merging unrelated changes into one commit makes it harder to understand and review them. One commit of 10 files is harder to understand than 10 trivial commits. Sometimes 10 changes are spread over 3 files where each file has about 3 unrelated edits. Enjoy your time reading and reviewing. If a developer is lazy to commit unrelated changes separately, then why should other people spend their time on sorting things out and review? You are lazy and we are lasy, high five, tl;dr. > > My opinion is that we should care more about readability rather than revision numbers. > > `v0.7.7.6+12` is pretty readable, isn't? I meant readability of patches. By saving a few revision numbers a developer wastes time of other developers. So, what is a more important resource to save: revision numbers or developer time? If we can keep it as short and readable as v0.7.7.6+, what is the reason to make it longer and less readable? > > Because the number of revisions is unlimited unlike the number of developers and amount of their time. > > Wdym? This structure should be initialized while building by script I mean the same thing as I described above. Ten trivial commits are easier to understand than a single commit of ten files, because firstly you have to somehow find out the changes are unrelated. It takes time of developers. The larger a commit is, the less a developer wants to review it. For example, I don't see many people reviewing this PR, even though they have been asking for git for years. Partially because the kernel commit addresses several issues at once and nobody wants to bother with it. > > Maybe switching to git is a great moment to drop revision numbers > > We do > > > and all kinds of commit counters completely and use just hashes and release tags. > > - Release tags for versions > - Hashes for precise identification of a commit and searching > - Offsets for night versions Why can't we use hashes for nightbuilds too? Why to introduce yet another entity of a tag offset?
db 'hash', 0 - a null-terminated git-hash string.
For example for KolibriOS v0.7.7-8672-g99ffedbae:
db 0,7,7
db 0
dd 1675
dw 8672
db '99ffedbae', 0
---------------------- Constants for registers: ----------------------
eax - SF_SYSTEM (18)
ebx - SSF_KERNEL_VERSION (13)
ebx - SSF_KERNEL_VERSION/SSF_OS_VERSION (13)
======================================================================
======= Function 18, subfunction 14 - wait for screen retrace. =======
======================================================================

View File

@ -91,7 +91,7 @@ pci_data_sel = pci_data_32-gdts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; That is a loading and initialization code that also draws the blue screen
; menu with svn revision number near top right corner of the screen.
; menu with version in the upper left corner of the screen.
include "bootbios.inc"
use32
@ -712,10 +712,10 @@ end if
;-----------------------------------------------------------------------------
; show SVN version of kernel on the message board
; show Git-hash of kernel on the message board
;-----------------------------------------------------------------------------
mov eax, [version_inf.rev]
DEBUGF 1, "K : kernel SVN r%d\n", eax
mov eax, version_inf.hash
DEBUGF 1, "K : kernel GIT %s\n", eax
;-----------------------------------------------------------------------------
; show CPU count on the message board
;-----------------------------------------------------------------------------
@ -2400,9 +2400,7 @@ endg
iglobal
version_inf:
db 0,7,7,0 ; version 0.7.7.0
db 0
.rev dd __REV__
include 'ver.inc'
.size = $ - version_inf
endg
;------------------------------------------------------------------------------
@ -4576,8 +4574,6 @@ end if
include "data32.inc"
__REV__ = __REV
if ~ lang eq sp
diff16 "end of kernel code",0,$
end if

View File

@ -1,20 +1,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__REV = 0
macro $Revision a {
match =: Num =$,a \{
if __REV < Num
__REV = Num
end if
\}
}
macro ignore_empty_revision_keyword {
; svn keywords are neither substituted by git-svn nor catched by $Revision
; macro above, ignore them to not fail the build

27
kernel/trunk/version-gen.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Copyright (C) KolibriOS team 2024. All rights reserved
# Distributed under terms of the GNU General Public License
full_ver=$(git describe --tag --long)
version=$(echo $full_ver | cut -d'-' -f1 | cut -c 2-)
offset=$(echo $full_ver | cut -d'-' -f2)
hash=$(echo $full_ver | cut -d'-' -f3 | cut -c 2-)
major=$(echo $version | cut -d'.' -f1)
minor=$(echo $version | cut -d'.' -f2)
patch=$(echo $version | cut -d'.' -f3)
short_ver=$(printf %-14s "$major.$minor.$patch-$offset")
cat > ver_boot.inc << EOF
db '$short_ver', 13,10,13,10,0
EOF
cat > ver.inc << EOF
db $major, $minor, $patch
db 0
dw $offset
.hash db '$hash', 0
EOF

View File

@ -759,6 +759,34 @@ KOSAPI void _ksys_shutdown(uint32_t 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. ========*/
KOSAPI size_t _ksys_get_ram_size(void)

View File

@ -6,16 +6,16 @@ void get_str_meminfo(char *str) {
}
int cmd_kfetch(char param[]) {
char *str_krnl_ver = malloc(64);
get_str_kernel_version(str_krnl_ver, "%d.%d.%d.%d. SVN-rev.: %d");
char *str_uptime = malloc(64);
char str_krnl_ver[64];
get_str_kernel_version(str_krnl_ver, "v%d.%d.%d-%d-g%s");
char str_uptime[64];
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();
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);
char *str_meminfo = malloc(24);
char str_meminfo[24];
get_str_meminfo(str_meminfo);
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;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;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;
}
}

View File

@ -1,52 +1,42 @@
void get_str_kernel_version(char *str, const char *fmt) {
char *kvbuf;
char *vA, *vB, *vC, *vD;
unsigned *Rev;
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);
ksys_os_ver_t ver;
_ksys_get_os_ver(&ver);
sprintf(str, fmt, ver.tag.major, ver.tag.minor, ver.tag.patch, ver.offset, ver.hash);
}
void get_str_cpu_info(char *str) {
unsigned a, b, c, d;
asm ("cpuid" :
"=a" (a),
"=b" (b),
"=c" (c),
"=d" (d):
"a"(0));
__asm__ __volatile__(
"cpuid"
:"=a" (a),
"=b" (b),
"=c" (c),
"=d" (d):
"a"(0)
);
str[0] = (b&0x000000ff) >> 0;
str[1] = (b&0x0000ff00) >> 8;
str[2] = (b&0x00ff0000) >> 16;
str[3] = (b&0xff000000) >> 24;
str[0] = (b & 0x000000ff) >> 0;
str[1] = (b & 0x0000ff00) >> 8;
str[2] = (b & 0x00ff0000) >> 16;
str[3] = (b & 0xff000000) >> 24;
str[4] = (d&0x000000ff) >> 0;
str[5] = (d&0x0000ff00) >> 8;
str[6] = (d&0x00ff0000) >> 16;
str[7] = (d&0xff000000) >> 24;
str[4] = (d & 0x000000ff) >> 0;
str[5] = (d & 0x0000ff00) >> 8;
str[6] = (d & 0x00ff0000) >> 16;
str[7] = (d & 0xff000000) >> 24;
str[8] = (c&0x000000ff) >> 0;
str[9] = (c&0x0000ff00) >> 8;
str[10] = (c&0x00ff0000) >> 16;
str[11] = (c&0xff000000) >> 24;
str[8] = (c & 0x000000ff) >> 0;
str[9] = (c & 0x0000ff00) >> 8;
str[10] = (c & 0x00ff0000) >> 16;
str[11] = (c & 0xff000000) >> 24;
str[12] = '\0';
}
int cmd_ver(char param[]) {
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);
return TRUE;
}
@ -61,4 +51,3 @@ int cmd_ver(char param[]) {
printf (" Shell v%s\n\r", SHELL_VERSION);
return TRUE;
}

View File

@ -58,8 +58,7 @@ const command_t COMMANDS[]=
#define CMD_RMDIR_USAGE " rmdir <directory>\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_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_UPTIME_FMT " Uptime: %d day(s), %d:%d:%d.%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_SCRIPT_ERROR_FMT "Error in '%s' : script must start with #SHS line\n\r"

View File

@ -15,12 +15,12 @@ const command_t COMMANDS[]=
{"free", " <20>®ª §ë¢ ¥â ®¡êñ¬ ®¯¥à â¨¢­®© ¯ ¬ïâ¨: ¢á¥©, ᢮¡®¤­®© ¨ ¨á¯®«ì§ã¥¬®©\n\r", &cmd_memory},
{"help", " ‘¯à ¢ª  ¯® ª®¬ ­¤ ¬. ˆá¯®«ì§®¢ ­¨¥:\n\r help ;ᯨ᮪ ¢á¥å ª®¬ ­¤\n\r help <ª®¬ ­¤ > ;á¯à ¢ª  ¯® ª®¬ ­¤¥\n\r", &cmd_help},
{"history", " ‘¯¨á®ª ¨á¯®«ì§®¢ ­­ëå ª®¬ ­¤\n\r", &cmd_history},
{"kfetch", " <20>¥ç â ¥â «®£® ¨ ¨­ä®à¬ æ¨î ® á¨á⥬¥.\n\r", &cmd_kfetch},
{"kfetch", " <20>¥ç â ¥â «®£® ¨ ¨­ä®à¬ æ¨î ® á¨á⥬¥.\n\r", &cmd_kfetch},
{"kill", " “¡¨¢ ¥â ¯à®æ¥áá. ˆá¯®«ì§®¢ ­¨¥:\n\r kill <PID ¯à®æ¥áá >\n\r kill all\n\r", &cmd_kill},
{"pkill", " “¡¨¢ ¥â ¢á¥ ¯à®æ¥ááë ¯® ¨¬¥­¨. ˆá¯®«ì§®¢ ­¨¥:\n\r pkill <¨¬ï_¯à®æ¥áá >\n\r", &cmd_pkill},
{"ls", " ‚뢮¤¨â ᯨ᮪ ä ©«®¢. ˆá¯®«ì§®¢ ­¨¥:\n\r ls ;ᯨ᮪ ä ©«®¢ ¢ ⥪ã饬 ª â «®£¥\n\r ls <¤¨à¥ªâ®à¨ï> ;ᯨ᮪ ä ©«®¢ ¨§ § ¤ ­­®© ¤¨à¥ªâ®à¨¨\n\r", &cmd_ls},
{"lsmod", " list working driver \n\r", &cmd_lsmod},
{"mkdir", " ‘®§¤ ¥â ª â «®£ ¨ த¨â¥«ì᪨¥ ª â «®£¨ ¯à¨ ­¥®¡å®¤¨¬®áâ¨. ˆá¯®«ì§®¢ ­¨¥:\n\r mkdir <¨¬ï/¯ ¯ª¨>", &cmd_mkdir},
{"mkdir", " ‘®§¤ ¥â ª â «®£ ¨ த¨â¥«ì᪨¥ ª â «®£¨ ¯à¨ ­¥®¡å®¤¨¬®áâ¨. ˆá¯®«ì§®¢ ­¨¥:\n\r mkdir <¨¬ï/¯ ¯ª¨>", &cmd_mkdir},
{"more", " ‚뢮¤¨â ᮤ¥à¦¨¬®¥ ä ©«  ­  íªà ­. ˆá¯®«ì§®¢ ­¨¥:\n\r more <¨¬ï ä ©« >\n\r", &cmd_more},
{"ps", " ‚뢮¤¨â ᯨ᮪ ¯à®æ¥áᮢ\n\r …᫨ 㪠§ ­® <¨¬ï¯à®æ¥áá >, ¯®ª §ë¢ ¥â ¡®«ìè¥ ¤ ­­ëå ¨ á®åà ­ï¥â LASTPID\n\r", &cmd_ps},
{"pwd", " <20>®ª §ë¢ ¥â ¨¬ï ⥪ã饩 ¤¨à¥ªâ®à¨¨\n\r", &cmd_pwd},
@ -59,10 +59,9 @@ const command_t COMMANDS[]=
#define CMD_SLEEP_USAGE " sleep <¨­â¥à¢ « ¢ á®âëå ¤®«ïx ᥪ㭤ë>\n\r"
#define CMD_TOUCH_USAGE " touch <¨¬ï ä ©« >\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 EXEC_STARTED_FMT " '%s' § ¯ã饭. PID = %d\n\r"
#define EXEC_SCRIPT_ERROR_FMT "Žè¨¡ª  ¢ '%s' : áªà¨¯â ¤®«¦¥­ ­ ç¨­ âìáï á® áâà®çª¨ #SHS\n\r"
#define UNKNOWN_CMD_ERROR " Žè¨¡ª !\n\r"
#define CON_APP_ERROR " Žè¨¡ª  ¢ ª®­á®«ì­®¬ ¯à¨«®¦¥­¨¨.\n\r"
#define FILE_NOT_FOUND_ERROR " ” ©« '%s' ­¥ ­ ©¤¥­.\n\r"
#define FILE_NOT_FOUND_ERROR " ” ©« '%s' ­¥ ­ ©¤¥­.\n\r"