Changes to get os version API for migrating to git

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>
This commit is contained in:
Max Logaev 2024-03-31 02:22:34 +03:00
parent 5bf9207b4b
commit fa4755138f
9 changed files with 68 additions and 72 deletions

View File

@ -872,8 +872,8 @@ for i,v in ipairs(img_files) do
-- note that .revision and .kernel.mnt must begin with . -- note that .revision and .kernel.mnt must begin with .
-- to prevent tup from tracking them -- to prevent tup from tracking them
if build_type == "rus" 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)' 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 +"[auto-build %d %b %Y %R, r$(get-current-revision)]")' else str='$(date -u +"[autobuild %d %b %Y %R, g$(git rev-parse --short HEAD)]")'
end end
str = string.gsub(str, "%$", "\\$") -- escape $ as \$ str = string.gsub(str, "%$", "\\$") -- escape $ as \$
str = string.gsub(str, "%%", "%%%%") -- escape % as %% str = string.gsub(str, "%%", "%%%%") -- escape % as %%
@ -899,7 +899,7 @@ end
-- generate tup rule for kolibri.iso -- generate tup rule for kolibri.iso
if tup.getconfig("INSERT_REVISION_ID") ~= "" 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" else volume_id = "KolibriOS"
end end
tup.definerule{inputs = input_deps, command = tup.definerule{inputs = input_deps, command =

View File

@ -1,8 +1,9 @@
if tup.getconfig("NO_FASM") ~= "" then return end 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("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.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"}}, "symbols %f %o", "kernel.mnt.sym")
--tup.rule({"kernel.mnt.fas", extra_inputs = {"kernel.mnt"}}, "listing %f %o", "kernel.mnt.lst") --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", "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"}}, "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 -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -31,18 +31,6 @@ macro line_space {
} }
d80x25_top: d80x25_top:
line_full_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: space_msg:
line_space line_space

View File

@ -24,7 +24,7 @@ org 0
; struct kernel_header ; struct kernel_header
jmp start_of_code ; jump jmp start_of_code ; jump
db 'KolibriOS ' ; signature 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 dd B32-KERNEL_BASE ; offset of the kernel's 32-bit entry point
include "boot/bootstr.inc" ; language-independent boot messages 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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.7.0 СИСТЕМНЫЕ ФУНКЦИИ KolibriOS 0.7.7-0+
Номер функции помещается в регистр eax. Номер функции помещается в регистр eax.
Вызов системной функции осуществляется командой "int 0x40". Вызов системной функции осуществляется командой "int 0x40".
@ -952,7 +952,7 @@ picture rb Xsize*Ysize*4 ; 32 бита
eax - SF_SYSTEM (18) eax - SF_SYSTEM (18)
ebx - SSF_INFO_DISC_SYS (11) ebx - SSF_INFO_DISC_SYS (11)
====================================================================== ======================================================================
========== Функция 18, подфункция 13 - получить версию ядра. ========= ========== Функция 18, подфункция 13 - получить версию ОС. ===========
====================================================================== ======================================================================
Параметры: Параметры:
* eax = 18 - номер функции * eax = 18 - номер функции
@ -962,25 +962,22 @@ picture rb Xsize*Ysize*4 ; 32 бита
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
но, если указатель в ecx недопустимый, например, но, если указатель в ecx недопустимый, например,
регион [ecx, ecx + 9) пересекается с памятью ядра, регион [ecx, ecx + 16) пересекается с памятью ядра,
то тогда функция возвращает -1 то тогда функция возвращает -1
Замечания:
* В данный момент используется только часть буфера размером
9 байт. Тем не менее рекомендуется использовать буфер
размером 16 байт для будущей совместимости, в будущем могут быть
добавлены некоторые поля.
Структура буфера: Структура буфера:
db a,b,c,d для версии a.b.c.d db major, minor, patch - git-тег
db 0: зарезервировано db 0 - зарезервировано для выравнивания git-тега до dword;
dd REV - номер svn-ревизии ядра dw offset - количество коммитов от git-тега;
Для ядра Kolibri 0.7.7.0+: db 'hash', 0 - нуль-терминированная строка git-хэша.
db 0,7,7,0 Например для KolibriOS v0.7.7-8672-g99ffedbae:
db 0,7,7
db 0 db 0
dd 1675 dw 8672
db '99ffedbae', 0
---------------------- Константы для регистров: ---------------------- ---------------------- Константы для регистров: ----------------------
eax - SF_SYSTEM (18) eax - SF_SYSTEM (18)
ebx - SSF_KERNEL_VERSION (13) ebx - SSF_KERNEL_VERSION/SSF_OS_VERSION (13)
====================================================================== ======================================================================
====================== Функция 18, подфункция 14 ===================== ====================== Функция 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 ;; ;; 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. Number of the function is located in the register eax.
The call of the system function is executed by "int 0x40" command. The call of the system function is executed by "int 0x40" command.
@ -944,7 +944,7 @@ Remarks:
eax - SF_SYSTEM (18) eax - SF_SYSTEM (18)
ebx - SSF_INFO_DISC_SYS (11) ebx - SSF_INFO_DISC_SYS (11)
====================================================================== ======================================================================
========== Function 18, subfunction 13 - get kernel version. ========= ========== Function 18, subfunction 13 - get OS version. =============
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 18 - function number * eax = 18 - function number
@ -954,25 +954,22 @@ Parameters:
Returned value: Returned value:
* function does not return value * function does not return value
but if pointer in ecx is illegal, for example, 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 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: Structure of the buffer:
db a,b,c,d for version a.b.c.d db major, minor, patch - git-tag;
db 0: reserved db 0 - reserved for alignment to dword;
dd REV - kernel SVN revision number dw offset - number of commits after git-tag;
For Kolibri 0.7.7.0+ kernel: db 'hash', 0 - a null-terminated git-hash string.
db 0,7,7,0 For example for KolibriOS v0.7.7-8672-g99ffedbae:
db 0,7,7
db 0 db 0
dd 1675 dw 8672
db '99ffedbae', 0
---------------------- Constants for registers: ---------------------- ---------------------- Constants for registers: ----------------------
eax - SF_SYSTEM (18) 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. ======= ======= 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 ; 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" include "bootbios.inc"
use32 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] mov eax, version_inf.hash
DEBUGF 1, "K : kernel SVN r%d\n", eax DEBUGF 1, "K : kernel GIT %s\n", eax
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; show CPU count on the message board ; show CPU count on the message board
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -2400,9 +2400,7 @@ endg
iglobal iglobal
version_inf: version_inf:
db 0,7,7,0 ; version 0.7.7.0 include 'ver.inc'
db 0
.rev dd __REV__
.size = $ - version_inf .size = $ - version_inf
endg endg
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -4576,8 +4574,6 @@ end if
include "data32.inc" include "data32.inc"
__REV__ = __REV
if ~ lang eq sp if ~ lang eq sp
diff16 "end of kernel code",0,$ diff16 "end of kernel code",0,$
end if 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 ;; ;; 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 { macro ignore_empty_revision_keyword {
; svn keywords are neither substituted by git-svn nor catched by $Revision ; svn keywords are neither substituted by git-svn nor catched by $Revision
; macro above, ignore them to not fail the build ; 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