Compare commits

..

1 Commits

Author SHA1 Message Date
bb075099b6 Shell: improve cpuid - view full brand string 2025-12-31 17:09:17 +03:00
8 changed files with 248 additions and 981 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ ehthumbs_vista.db
._*
programs/cmm/cmm.code-workspace
programs/cmm/menu/.gitignore
.vscode

View File

@@ -401,9 +401,8 @@ tup.append_table(img_files, {
{"@MENU", VAR_PROGS .. "/system/menu/trunk/menu"},
{"@NOTIFY", VAR_PROGS .. "/system/notify3/notify"},
{"@OPEN", VAR_PROGS .. "/system/open/open"},
{"@RESHARE", VAR_PROGS .. "/system/reshare/reshare"},
{"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"},
{"@TASKBAR", VAR_PROGS .. "/system/taskbar/trunk/TASKBAR"},
{"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"},
{"@VOLUME", VAR_PROGS .. "/media/volume/volume"},
{"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"},
{"ACLOCK", VAR_PROGS .. "/demos/aclock/aclock"},
@@ -662,6 +661,7 @@ end -- tup.getconfig('NO_JWASM') ~= 'full'
-- Programs that require C-- to compile.
if tup.getconfig('NO_CMM') ~= 'full' then
tup.append_table(img_files, {
{"@RESHARE", VAR_PROGS .. "/cmm/misc/reshare.com"},
{"APP_PLUS", VAR_PROGS .. "/cmm/app_plus/app_plus.com"},
{"EASYSHOT", VAR_PROGS .. "/cmm/misc/easyshot.com"},
{"MOUSECFG", VAR_PROGS .. "/cmm/mousecfg/mousecfg.com"},

View File

@@ -1,4 +0,0 @@
if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua")
tup.rule("reshare.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o" .. tup.getconfig("KPACK_CMD"), "%B")

View File

@@ -1,71 +0,0 @@
; SPDX-License-Identifier: GPL-2.0-only
;
; Reshare - Shared Resources Daemon
; Copyright (C) 2024 KolibriOS-NG Team
;
; Contributor rgmaid - Main code
; Contributor Burer - Image conversion from 8bpp
; ====================================================================
CBOX_WIDTH = 13
CBOX_HEIGHT = 13
CBOX_PIXELS = CBOX_WIDTH * CBOX_HEIGHT
CBOX_IMG_SIZE = CBOX_PIXELS * 3 ; 24-bpp RGB, tight rows
; ====================================================================
macro RGB24 c
{
db (c) and 0xFF, (c shr 8) and 0xFF, (c shr 16) and 0xFF
}
macro ROW13 c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, c11, c12
{
RGB24 c00
RGB24 c01
RGB24 c02
RGB24 c03
RGB24 c04
RGB24 c05
RGB24 c06
RGB24 c07
RGB24 c08
RGB24 c09
RGB24 c10
RGB24 c11
RGB24 c12
}
P00 = 0x04D4FC ; 0xRRGGBB
P01 = 0x04C8FC
P02 = 0x04DCFC
P03 = 0x04B4FC
P04 = 0x04BCFC
P05 = 0x04A9FC
P06 = 0x0498F9
P07 = 0xD2F2FC
P08 = 0x04A5FA
P09 = 0xFFFFFF
P10 = 0xF6FDFD
P11 = 0xAFF9FC
P12 = 0x95E0F7
P13 = 0x0464BC
P14 = 0x2CDCFC
P15 = 0x049FFA
cbox_image:
ROW13 P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P01
ROW13 P02, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P03
ROW13 P02, P01, P01, P01, P01, P04, P04, P04, P03, P05, P05, P03, P03
ROW13 P00, P01, P01, P01, P04, P04, P03, P03, P06, P07, P07, P08, P03
ROW13 P00, P03, P05, P05, P03, P03, P03, P06, P09, P10, P11, P06, P03
ROW13 P00, P05, P07, P07, P06, P03, P06, P09, P10, P12, P13, P06, P05
ROW13 P00, P06, P10, P09, P14, P06, P09, P10, P12, P13, P06, P15, P05
ROW13 P00, P06, P12, P10, P09, P09, P10, P12, P13, P06, P15, P05, P05
ROW13 P00, P06, P13, P12, P10, P10, P12, P13, P06, P15, P05, P05, P05
ROW13 P01, P08, P06, P13, P12, P12, P13, P06, P15, P05, P05, P05, P15
ROW13 P01, P05, P15, P06, P13, P13, P06, P15, P05, P05, P05, P15, P15
ROW13 P01, P05, P05, P15, P06, P06, P15, P05, P05, P05, P15, P15, P06
ROW13 P03, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06
align 4

View File

@@ -1,666 +0,0 @@
; SPDX-License-Identifier: GPL-2.0-only
;
; Reshare - Shared Resources Daemon
; Copyright (C) 2024-2025 KolibriOS/-NG Team
;
; Contributor Leency - Original version in C--
; Contributor rgmaid - Main code
; Contributor Burer - Refactoring and localization
; ====================================================================
use32
org 0
; ====================================================================
db "MENUET01"
dd 1
dd START
dd I_END
dd MEM
dd STACKTOP
dd 0
dd 0
; ====================================================================
include "../../macros.inc"
include "../../KOSfuncs.inc"
include "../../encoding.inc"
include "../../proc32.inc"
include "../../dll.inc"
include "../../debug-fdo.inc"
include "../../develop/libraries/libs-dev/libimg/libimg.inc"
include "checkbox.inc"
; ====================================================================
LIBS:
library img, "libimg.obj"
import img, img.destroy, "img_destroy", \
img.from_file, "img_from_file"
; ====================================================================
START:
mcall SF_SYS_MISC, SSF_HEAP_INIT
mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1
; check if this is second instance of app. if so - run gui, else - run daemon
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ
test eax, eax
jz MODE_DAEMON
jmp MODE_GUI
.exit:
mcall SF_TERMINATE_PROCESS
; ====================================================================
MODE_GUI:
.event_loop:
mcall SF_WAIT_EVENT
cmp eax, EV_REDRAW
je .event_redraw
cmp eax, EV_KEY
je .event_key
cmp eax, EV_BUTTON
je .event_button
jmp .event_loop
.event_redraw:
mcall SF_REDRAW, SSF_BEGIN_DRAW
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
mcall , SSF_GET_SKIN_HEIGHT
mov ecx, WIN.Y shl 16 + WIN.H
add ecx, eax
mov edx, [sc.work]
add edx, 0x34000000
mcall SF_CREATE_WINDOW, <WIN.X, WIN.W>, , , , title
; visual dividers
mcall SF_DRAW_RECT, <PAD, GRID.W>, <BTN.Y + BTN.H + GAP, 1>, [sc.work_graph]
mcall , , <GRID.Y + GRID.H, 1>,
; info row
mov ecx, FONT_TYPE shl 24
add ecx, [sc.work_text]
mcall SF_DRAW_TEXT, <PAD, GRID.Y + GRID.H + 1 + GAP>, , lb_info
; tabs labels
mcall , <TAB_STEP * 0 + PAD * 2, BTN.Y>, , lb_tab_i32
mcall , <TAB_STEP * 0 + PAD * 2 + 1, BTN.Y>, ,
mcall , <TAB_STEP * 0 + PAD *11, BTN.Y>, , lb_tab_i32_res
mcall , <TAB_STEP * 1 + PAD * 2, BTN.Y>, , lb_tab_i18
mcall , <TAB_STEP * 1 + PAD * 2 + 1, BTN.Y>, ,
mcall , <TAB_STEP * 1 + PAD *11, BTN.Y>, , lb_tab_i18_res
mcall , <TAB_STEP * 2 + PAD * 2, BTN.Y>, , lb_tab_i18w
mcall , <TAB_STEP * 2 + PAD * 2 + 1, BTN.Y>, ,
mcall , <TAB_STEP * 2 + PAD *11, BTN.Y>, , lb_tab_i18_res
mcall , <TAB_STEP * 3 + PAD * 2, BTN.Y>, , lb_tab_cbox
mcall , <TAB_STEP * 3 + PAD * 2 + 1, BTN.Y>, ,
mcall , <TAB_STEP * 3 + PAD *11, BTN.Y>, , lb_tab_cbox_res
; tabs buttons
mcall SF_DEFINE_BUTTON, <TAB_STEP * 0 + PAD, BTN.W>, <BTN.Y, BTN.H>, 10 + BTN_HIDE + ACTIVE_ICONS32
mcall , <TAB_STEP * 1 + PAD, BTN.W>, , 10 + BTN_HIDE + ACTIVE_ICONS18
mcall , <TAB_STEP * 2 + PAD, BTN.W>, , 10 + BTN_HIDE + ACTIVE_ICONS18W
mcall , <TAB_STEP * 3 + PAD, BTN.W>, , 10 + BTN_HIDE + ACTIVE_CHECKBOX
; tabs content
call draw_tabs
mcall SF_REDRAW, SSF_END_DRAW
jmp .event_loop
.event_key:
mcall SF_GET_KEY
cmp ah, 15 ; TAB
jne .event_loop
shl [active_tab], 1 ; * 2
cmp [active_tab], ACTIVE_CHECKBOX
jbe .tab_draw
mov [active_tab], 1
.tab_draw:
call draw_tabs
jmp .event_loop
.event_button:
mcall SF_GET_BUTTON
cmp ah, 1
je .event_exit
movzx eax, ah
sub eax, 10
mov [active_tab], eax
call draw_tabs
jmp .event_loop
.event_exit:
mcall SF_TERMINATE_PROCESS
; ====================================================================
draw_tabs:
; draw tabs headers underlines
mov esi, [active_tab]
xor edi, edi
.loop:
mov edx, [sc.work_dark]
mov eax, [tab_masks + edi * 4]
test esi, eax
jz .color_ok
mov edx, [sc.work_button]
.color_ok:
mov eax, edi
imul eax, TAB_STEP
add eax, PAD
mpack ebx, eax, BTN.W
mpack ecx, PAD + BTN.H + 2, 2
mcall SF_DRAW_RECT, ebx, ecx, edx
inc edi
cmp edi, TAB_COUNT
jb .loop
; draw current tab content
mcall SF_DRAW_RECT, <GRID.X, GRID.W>, <GRID.Y, GRID.H>, [sc.work]
mov eax, [active_tab]
.tab_i32:
cmp eax, ACTIVE_ICONS32
jne .tab_i18
stdcall draw_tab_icons, lb_tab_i32, META_I32_C, META_I32_W
ret
.tab_i18:
cmp eax, ACTIVE_ICONS18
jne .tab_i18w
stdcall draw_tab_icons, lb_tab_i18, META_I18_C, META_I18_W
ret
.tab_i18w:
cmp eax, ACTIVE_ICONS18W
jne .tab_cbox
stdcall draw_tab_icons, lb_tab_i18w, META_I18W_C, META_I18W_W
ret
.tab_cbox:
stdcall draw_tab_cbox
ret
proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ
test eax, eax
jz .done
mov ebx, [_meta_c_off]
mov ecx, [eax + ebx] ; icon_c
mov ebx, [_meta_w_off]
mov edx, [eax + ebx] ; icon_w
test ecx, ecx
jz .done
test edx, edx
jz .done
push ecx
push edx
mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], 0, SHM_OPEN + SHM_READ
pop edx
pop ecx
test eax, eax
jz .done
mov ebx, eax
stdcall draw_tab_icons_grid, ebx, ecx, edx
mcall SF_SYS_MISC, SSF_MEM_CLOSE, [_shm_name]
mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name
.done:
ret
endp
proc draw_tab_icons_grid stdcall uses eax ebx ecx edx esi edi, _icon_img, _icon_c, _icon_w
locals
x dd 0
x_off dd 0
y dd 0
icon_size dd 0
endl
; icon_bytes = icon_w * icon_w * 4
mov eax, [_icon_w]
imul eax, eax
shl eax, 2
mov [icon_size], eax
; x_off = (CELL.W - icon_w) / 2
mov eax, CELL.W
sub eax, [_icon_w]
shr eax, 1
mov [x_off], eax
; y_step = icon_w + 28
mov eax, [_icon_w]
add eax, 28
mov edi, eax
xor ecx, ecx
.for_icons:
cmp ecx, [_icon_c]
jae .end_for_icons
push ecx
; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, <x+x_off, y+RES_Y>, 32, 0, 0
mov ebx, [icon_size]
imul ebx, ecx
add ebx, [_icon_img]
mov ecx, [_icon_w]
shl ecx, 16
add ecx, [_icon_w]
mov edx, [x]
add edx, [x_off]
shl edx, 16
add edx, [y]
add edx, GRID.Y
push edi
push ebp
mcall SF_PUT_IMAGE_EXT, , , , 32, 0, 0
pop ebp
pop edi
; DrawNumber with no leading zeros, centered in CELL.W
mov edx, [x]
add edx, GAP
shl edx, 16
add edx, [y]
add edx, [_icon_w]
add edx, GRID.Y + 4
mov esi, 0x10000000
add esi, [sc.work_graph]
pop ecx
mcall SF_DRAW_NUMBER, 0x00030000, , , ,
inc ecx
add [x], CELL.W
cmp [x], WIN.W - CELL.W
jle .for_icons
mov [x], 0
add [y], edi
jmp .for_icons
.end_for_icons:
ret
endp
proc draw_tab_cbox stdcall
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, 0, SHM_OPEN + SHM_READ
test eax, eax
jz .done
mov ebx, eax
mcall SF_PUT_IMAGE, , \
<CBOX_WIDTH, CBOX_HEIGHT>, \
<(WIN.W - CBOX_WIDTH)/2, (WIN.H - RES_Y - CBOX_HEIGHT)/2 + RES_Y>
mcall SF_SYS_MISC, SSF_MEM_CLOSE, lb_tab_cbox
.done:
ret
endp
; ====================================================================
MODE_DAEMON:
stdcall dll.Load, LIBS
; load shared resources from files
DEBUGF DBG_INFO, "I: @reshare: loading resources...\n"
stdcall load_icons, icons32_path, icons32_image, size32
stdcall load_icons, icons18_path, icons18_image, size18
; publish meta
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, META_SIZE, SHM_CREATE + SHM_WRITE
test eax, eax
jz .meta_done
mov edi, eax
xor ebx, ebx
xor ecx, ecx
mov eax, [icons32_image]
test eax, eax
jz .i32_set
mov ebx, [eax + Image.Width]
mov eax, [eax + Image.Height]
test ebx, ebx
jz .i32_set
xor edx, edx
div ebx
mov ecx, eax
.i32_set:
mov [edi + META_I32_W], ebx
mov [edi + META_I32_C], ecx
xor ebx, ebx
xor ecx, ecx
mov eax, [icons18_image]
test eax, eax
jz .i18_set
mov ebx, [eax + Image.Width]
mov eax, [eax + Image.Height]
test ebx, ebx
jz .i18_set
xor edx, edx
div ebx
mov ecx, eax
.i18_set:
mov [edi + META_I18_W], ebx
mov [edi + META_I18_C], ecx
mov [edi + META_I18W_W], ebx
mov [edi + META_I18W_C], ecx
mov dword [edi + META_CBOX_W], CBOX_WIDTH
mov dword [edi + META_CBOX_H], CBOX_HEIGHT
mov dword [edi + META_CBOX_SIZE], CBOX_IMG_SIZE
.meta_done:
DEBUGF DBG_INFO, "I: @reshare: starting in daemon mode\n"
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE
test eax, eax
jz .skip_cbox
mov esi, cbox_image
mov edi, eax
mov ecx, CBOX_IMG_SIZE
cld
rep movsb
.skip_cbox:
cmp [icons32_image], 0
jz .skip_i32
stdcall copy_image_to_shm, lb_tab_i32, size32, icons32_image
test eax, eax
jz .skip_i32
invoke img.destroy, [icons32_image]
.skip_i32:
cmp [icons18_image], 0
jz .skip_i18
stdcall copy_image_to_shm, lb_tab_i18, size18, icons18_image
test eax, eax
jz .skip_i18
mov [shared_i18], eax
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_i18w, [size18], SHM_CREATE + SHM_WRITE
test eax, eax
jz .skip_i18
mov [shared_i18w], eax
invoke img.destroy, [icons18_image]
mov dword [icons18_image], 0
.skip_i18:
mcall SF_SET_EVENTS_MASK, EVM_BACKGROUND
.event_loop:
push [sc.work]
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
pop eax
cmp eax, [sc.work]
je .wait_event
cmp [shared_i18], 0
jz .wait_event
cmp [shared_i18w], 0
jz .wait_event
mov esi, [shared_i18]
mov edi, [shared_i18w]
mov ecx, [size18]
shr ecx, 2 ; / 4 to get size in dwords
cld
rep movsd
stdcall replace_2cols, [shared_i18w], [size18], 0xFFFFFFFF, [sc.work], 0xFFCACBD6, [sc.work_dark]
.wait_event:
mcall SF_WAIT_EVENT
cmp eax, EV_BACKGROUND
je .event_loop
jmp .wait_event
; ====================================================================
proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr
invoke img.from_file, [_path]
test eax, eax
jz .fail
mov ebx, [_img_ptr]
mov [ebx], eax
mov ebx, [eax + Image.Width]
mov ecx, [eax + Image.Height]
imul ecx, ebx
shl ecx, 2 ; * 4 to get size in bytes
mov ebx, [_size_ptr]
mov [ebx], ecx
ret
.fail:
DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\n", [_path]
ret
endp
proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _image_ptr
mov edx, [_size_ptr]
mov edx, [edx]
mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], edx, SHM_CREATE + SHM_WRITE
test eax, eax
jz .done
mov ebx, [_image_ptr]
mov ebx, [ebx]
mov esi, [ebx + Image.Data]
mov edi, eax
mov ecx, [_size_ptr]
mov ecx, [ecx]
shr ecx, 2 ; / 4 to get size in dwords
cld
rep movsd
.done:
ret
endp
proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, color_old_2, color_new_2
mov edx, [imgsize]
add edx, [imgsrc]
mov edi, [imgsrc]
.loop:
cmp edi, edx
jae .done
mov eax, [edi]
cmp eax, [color_old_1]
jne .check_second
mov eax, [color_new_1]
mov [edi], eax
jmp .next
.check_second:
cmp eax, [color_old_2]
jne .next
mov eax, [color_new_2]
mov [edi], eax
.next:
add edi, 4
jmp .loop
.done:
ret
endp
; ====================================================================
BORD = 5
PAD = 8
GAP = 12
GRID_COLS = 16
GRID_ROWS = 9
RES_Y = BTN.Y + BTN.H + PAD * 2 + 1
TAB_STEP = BTN.W + PAD * 2
WIN RECT 80, 50, GRID.W + PAD * 2 + BORD * 2, 638
BTN RECT 0, PAD + 4, CELL.W * 4 - PAD * 2 , 22
CELL RECT 0, 0, 32 + PAD * 2 , 60
GRID RECT PAD, RES_Y + PAD, CELL.W * GRID_COLS - PAD * 2, CELL.H * GRID_ROWS
FONT_TYPE = 0x90
BTN_HIDE = 0x60000000
; ====================================================================
if lang eq ru_RU
title cp866 "@RESHARE - Служба общих ресурсов", 0
lb_info cp866 "Имя каждой вкладки соответствует имени области памяти, доступной через сисфункцию 68.22.", 0
else if lang eq es_ES
title db "@RESHARE - Servicio de recursos compartidos", 0
lb_info db "Cada nombre de pestana corresponde al nombre de memoria accesible mediante sysfunc 68.22.", 0
else
title cp850 "@RESHARE - Shared resources service", 0
lb_info cp850 "Each tab name corresponds to shared memory page name that can be accessed via sysfunc 68.22.", 0
endf
lb_tab_i32 db "ICONS32", 0
lb_tab_i18 db "ICONS18", 0
lb_tab_i18w db "ICONS18W", 0
lb_tab_cbox db "CHECKBOX", 0
lb_tab_i32_res db "32x32x32bpp", 0
lb_tab_i18_res db "18x18x32bpp", 0
lb_tab_cbox_res db "13x13x24bpp", 0
; ====================================================================
DBG_ALL = 0 ; all messages
DBG_INFO = 1 ; info and errors
DBG_ERR = 2 ; only errors
__DEBUG__ = 1
__DEBUG_LEVEL__ = DBG_ERR
SHM_OPEN = 0x00
SHM_READ = 0x00
SHM_WRITE = 0x01
SHM_OPEN_ALWAYS = 0x04
SHM_CREATE = 0x08
ACTIVE_ICONS32 = 1
ACTIVE_ICONS18 = 2
ACTIVE_ICONS18W = 4
ACTIVE_CHECKBOX = 8
TAB_COUNT = 4
META_I32_C = 0
META_I32_W = 4
META_I18_C = 8
META_I18_W = 12
META_I18W_C = 16
META_I18W_W = 20
META_CBOX_W = 24
META_CBOX_H = 28
META_CBOX_SIZE = 32
META_SIZE = 36
tab_masks dd ACTIVE_ICONS32, ACTIVE_ICONS18, ACTIVE_ICONS18W, ACTIVE_CHECKBOX
; ====================================================================
meta_name db "RESHARE_META", 0
icons32_path db "/SYS/ICONS32.PNG", 0
icons18_path db "/SYS/ICONS16.PNG", 0
; pointers to Image structures
icons32_image dd 0
icons18_image dd 0
; sizes of icons image data in bytes
size32 dd 0
size18 dd 0
; currenly selected i18w section
shared_i18 dd 0
shared_i18w dd 0
active_tab dd ACTIVE_ICONS32
sc system_colors
include_debug_strings
; ====================================================================
I_END:
rb 4096
align 16
STACKTOP:
MEM:

View File

@@ -26,8 +26,8 @@ int cmd_kfetch(char param[]) {
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[16];
get_str_cpu_info(str_cpu_info);
char str_cpu_info[50];
get_cpu_brand_string(str_cpu_info);
char str_meminfo[24];
get_str_meminfo(str_meminfo);
@@ -53,7 +53,7 @@ int cmd_kfetch(char param[]) {
"\033[0;34;40m \033[0;31;40m \033[0;32;40mS\033[0;34;40m@\033[0;5;34;40mX\033[0;1;35;45m.\033[0;1;34;44m8\033[0;5;35;45m \033[0;5;34;44m \033[0;1;30;45m8\033[0;5;35;44m:\033[0;5;37;45m@\033[0;1;30;40m8\033[0;31;40m.\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0m\n\r"
"\033[0;34;40m \033[0;31;40m \033[0;32;40m \033[0;31;40m.\033[0;32;40m;\033[0;34;40m;8\033[0;32;40m%%\033[0;5;34;40m8\033[0;34;40m8\033[0;1;30;44m8\033[0;1;30;40m8\033[0;34;40m;.\033[0;31;40m \033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0m\n\r"
"\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[0;31;40m \033[0;34;40m \033[0m\n\r",
"\033[0;36mOS\033[0m: KolibriOS ", str_os_rel_offset_dbgtag, "\033[0;36mKernel\033[0m: ", str_krn_abi_cmtid, "\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
);

View File

@@ -1,65 +1,72 @@
#include "../system/kolibri.h"
void get_str_kernel_version(char *str, const char *fmt) {
struct kernel_version kv;
kol_get_kernel_ver(&kv);
char str_offset[8] = {'\0'};
if (kv.offset)
sprintf(str_offset, "+%u", kv.offset);
char str_dbgtag[4] = {'\0'};
if (kv.dbgtag)
sprintf(str_dbgtag, "-%c", kv.dbgtag);
char str_cmtid[16] = {'\0'};
if (kv.cmtid)
sprintf(str_cmtid, " (%08x)", kv.cmtid);
sprintf(str, fmt, kv.osrel[0], kv.osrel[1], kv.osrel[2], kv.osrel[3],
str_offset, str_dbgtag, str_cmtid, kv.abimaj, kv.abimin);
}
void get_str_cpu_info(char *str) {
unsigned a, b, c, d;
asm ("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[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[12] = '\0';
}
int cmd_ver(char param[]) {
if (!strcmp(param, "kernel")) {
get_str_kernel_version(tmpstr, CMD_VER_FMT1);
printf(tmpstr);
return TRUE;
}
if (!strcmp(param, "cpu")) {
char str[13];
get_str_cpu_info(str);
printf("%s\n\r", str);
return TRUE;
}
printf (" Shell v%s\n\r", SHELL_VERSION);
return TRUE;
}
#include "../system/kolibri.h"
void get_str_kernel_version(char *str, const char *fmt) {
struct kernel_version kv;
kol_get_kernel_ver(&kv);
char str_offset[8] = {'\0'};
if (kv.offset)
sprintf(str_offset, "+%u", kv.offset);
char str_dbgtag[4] = {'\0'};
if (kv.dbgtag)
sprintf(str_dbgtag, "-%c", kv.dbgtag);
char str_cmtid[16] = {'\0'};
if (kv.cmtid)
sprintf(str_cmtid, " (%08x)", kv.cmtid);
sprintf(str, fmt, kv.osrel[0], kv.osrel[1], kv.osrel[2], kv.osrel[3],
str_offset, str_dbgtag, str_cmtid, kv.abimaj, kv.abimin);
}
// Retrieves the CPU Brand String and writes it to the provided buffer.
// out_buffer: A buffer of at least 49 bytes (48 for string + 1 for null)
void get_cpu_brand_string(char *out_buffer) {
if (!out_buffer) return;
uint32_t regs[4];
// 1. Check maximum extended function support
__asm__ (
"cpuid"
: "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
: "a" (0x80000000)
);
if (regs[0] < 0x80000004) {
strcpy(out_buffer, "Brand String Not Supported");
return;
}
// 2. Extract brand string from leaves 0x80000002 to 0x80000004
for (uint32_t leaf = 0x80000002; leaf <= 0x80000004; leaf++) {
__asm__ (
"cpuid"
: "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
: "a" (leaf)
);
// Copy the 16 bytes (4 registers * 4 bytes) from this leaf into the buffer
memcpy(out_buffer + (leaf - 0x80000002) * 16, regs, 16);
}
out_buffer[48] = '\0';
}
int cmd_ver(char param[]) {
if (!strcmp(param, "kernel")) {
get_str_kernel_version(tmpstr, CMD_VER_FMT1);
printf(tmpstr);
return TRUE;
}
if (!strcmp(param, "cpu")) {
char str[49];
get_cpu_brand_string(str);
printf("%s\n\r", str);
return TRUE;
}
printf (" Shell v%s\n\r", SHELL_VERSION);
return TRUE;
}

View File

@@ -1,170 +1,170 @@
#include "all.h"
int dir_check(char dir[])
/// just checks, if dir[] is really a directory
{
kol_struct70 k70;
int result;
k70.p00 = 1;
k70.p04 = 0;
//k70.p08 = 0;
k70.p12 = 2; // enough to read . & ..
k70.p16 = (unsigned)malloc(32+k70.p12*560);
k70.p20 = 0;
k70.p21 = dir;
result = kol_file_70(&k70);
free((void*)k70.p16);
if ( (0 == result)||(6 == result) ) // 6 is possible ???
return TRUE;
else
return FALSE;
}
void dir_truncate(char dir[])
{
int i;
i = strlen(dir)-1;
for (;;i--)
if ('/' == dir[i])
{
dir[i+1] = 0;
break;
}
}
void get_file_dir_loc(char *filepath, char *dir_path)
{
char *res = strrchr(filepath, '/');
if (res == 0)
{
dir_path = '\0';
return;
}
size_t pos = res - filepath;
strncpy(dir_path, filepath, pos);
dir_path[pos] = '\0';
}
int file_check(char file[])
{
kol_struct70 k70;
int result;
k70.p00 = 0;
k70.p04 = 0;
//k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = file;
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}
void file_not_found(char file[]) {
printf (FILE_NOT_FOUND_ERROR, file);
}
int iswhite(char c) {return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); }
void trim(char string[])
{
int i, j;
for (i=0; ;i++)
if ( !iswhite(string[i]) )
break;
j = 0;
for (;;i++, j++)
{
string[j] = string[i];
if ('\0' == string[i] )
break;
}
for (i=0; ;i++)
if ('\0' == string[i])
break;
i--;
for (;i>0;--i)
if ( iswhite(string[i]) )
string[i] = '\0';
else
break;
}
// entry point
int main(int argc, char **argv)
{
int i; for (i = 1; i < argc; i++) {
strcat(cmdline, argv[i]);
if (i != argc - 1) {
strcat(cmdline, " ");
}
}
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
strcpy(title, "SHELL ");
strcat(title, SHELL_VERSION);
con_init_opt(-1, -1, -1, -1, title);
//printf("argc = %d\ncmdline = '%s'\n", argc, cmdline);
if (sizeof (kol_struct70) != 25) {
printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
kol_exit();
}
//strcpy(cur_dir, PATH);
//dir_truncate(cur_dir);
getcwd(cur_dir, sizeof cur_dir);
//printf("curdir %s\n", cur_dir);
con_set_cursor_height(con_get_font_height()-1);
ALIASES = malloc(128*1024);
if (!cmdline || cmdline[0] == 0) {
strcpy(CMD, argv[0]);
dir_truncate(CMD);
strcat(CMD, ".shell");
if ( !file_check(CMD) )
strcpy(CMD, "/sys/settings/.shell");
}
else {
if (cmdline[0] == '/')
{
strcpy(cur_dir, cmdline);
*(strrchr(cur_dir, '/')+1)=0;
}
strcpy(CMD, cmdline);
}
command_execute();
for (;;) {
//printf("\033[32;1m");
printf ("# ");
//printf("\033[0m");
command_get();
command_execute();
}
con_exit(0);
kol_exit();
}
#include "all.h"
int dir_check(char dir[])
/// just checks, if dir[] is really a directory
{
kol_struct70 k70;
int result;
k70.p00 = 1;
k70.p04 = 0;
//k70.p08 = 0;
k70.p12 = 2; // enough to read . & ..
k70.p16 = (unsigned)malloc(32+k70.p12*560);
k70.p20 = 0;
k70.p21 = dir;
result = kol_file_70(&k70);
free((void*)k70.p16);
if ( (0 == result)||(6 == result) ) // 6 is possible ???
return TRUE;
else
return FALSE;
}
void dir_truncate(char dir[])
{
int i;
i = strlen(dir)-1;
for (;;i--)
if ('/' == dir[i])
{
dir[i+1] = 0;
break;
}
}
void get_file_dir_loc(char *filepath, char *dir_path)
{
char *res = strrchr(filepath, '/');
if (res == 0)
{
dir_path = '\0';
return;
}
size_t pos = res - filepath;
strncpy(dir_path, filepath, pos);
dir_path[pos] = '\0';
}
int file_check(char file[])
{
kol_struct70 k70;
int result;
k70.p00 = 0;
k70.p04 = 0;
//k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = file;
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}
void file_not_found(char file[]) {
printf (FILE_NOT_FOUND_ERROR, file);
}
int iswhite(char c) {return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); }
void trim(char string[])
{
int i, j;
for (i=0; ;i++)
if ( !iswhite(string[i]) )
break;
j = 0;
for (;;i++, j++)
{
string[j] = string[i];
if ('\0' == string[i] )
break;
}
for (i=0; ;i++)
if ('\0' == string[i])
break;
i--;
for (;i>0;--i)
if ( iswhite(string[i]) )
string[i] = '\0';
else
break;
}
// entry point
int main(int argc, char **argv)
{
int i; for (i = 1; i < argc; i++) {
strcat(cmdline, argv[i]);
if (i != argc - 1) {
strcat(cmdline, " ");
}
}
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
strcpy(title, "SHELL ");
strcat(title, SHELL_VERSION);
con_init_opt(-1, -1, -1, -1, title);
//printf("argc = %d\ncmdline = '%s'\n", argc, cmdline);
if (sizeof (kol_struct70) != 25) {
printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
kol_exit();
}
//strcpy(cur_dir, PATH);
//dir_truncate(cur_dir);
getcwd(cur_dir, sizeof cur_dir);
//printf("curdir %s\n", cur_dir);
con_set_cursor_height(con_get_font_height()-1);
ALIASES = malloc(128*1024);
if (!cmdline || cmdline[0] == 0) {
strcpy(CMD, argv[0]);
dir_truncate(CMD);
strcat(CMD, ".shell");
if ( !file_check(CMD) )
strcpy(CMD, "/sys/settings/.shell");
}
else {
if (cmdline[0] == '/')
{
strcpy(cur_dir, cmdline);
*(strrchr(cur_dir, '/')+1)=0;
}
strcpy(CMD, cmdline);
}
command_execute();
for (;;) {
//printf("\033[32;1m");
printf ("# ");
//printf("\033[0m");
command_get();
command_execute();
}
con_exit(0);
kol_exit();
}