From fa4755138f9f14c5b82ef2ae678f2b762a5c23ab Mon Sep 17 00:00:00 2001 From: Maxim Logaev Date: Sun, 31 Mar 2024 02:22:34 +0300 Subject: [PATCH] Changes to get os version API for migrating to git Signed-off-by: Maxim Logaev --- data/Tupfile.lua | 6 +++--- kernel/trunk/Tupfile.lua | 7 ++++--- kernel/trunk/boot/bootstr.inc | 14 +------------- kernel/trunk/bootbios.inc | 2 +- kernel/trunk/docs/sysfuncr.txt | 29 +++++++++++++---------------- kernel/trunk/docs/sysfuncs.txt | 29 +++++++++++++---------------- kernel/trunk/kernel.asm | 14 +++++--------- kernel/trunk/macros.inc | 12 +----------- kernel/trunk/version-gen.sh | 27 +++++++++++++++++++++++++++ 9 files changed, 68 insertions(+), 72 deletions(-) create mode 100755 kernel/trunk/version-gen.sh diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 1c8b4529ac..7475c07b03 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -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)]")' 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 = diff --git a/kernel/trunk/Tupfile.lua b/kernel/trunk/Tupfile.lua index cfcc3610c8..44c2e0f641 100644 --- a/kernel/trunk/Tupfile.lua +++ b/kernel/trunk/Tupfile.lua @@ -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") diff --git a/kernel/trunk/boot/bootstr.inc b/kernel/trunk/boot/bootstr.inc index 1fd52d5267..fd120de4f9 100644 --- a/kernel/trunk/boot/bootstr.inc +++ b/kernel/trunk/boot/bootstr.inc @@ -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 diff --git a/kernel/trunk/bootbios.inc b/kernel/trunk/bootbios.inc index beb3d2f204..b95b16e675 100644 --- a/kernel/trunk/bootbios.inc +++ b/kernel/trunk/bootbios.inc @@ -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 diff --git a/kernel/trunk/docs/sysfuncr.txt b/kernel/trunk/docs/sysfuncr.txt index 0ba3c92d89..8ff8faa141 100644 --- a/kernel/trunk/docs/sysfuncr.txt +++ b/kernel/trunk/docs/sysfuncr.txt @@ -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 ===================== ======= Ожидать начала обратного хода луча развёртки монитора. ======= diff --git a/kernel/trunk/docs/sysfuncs.txt b/kernel/trunk/docs/sysfuncs.txt index a70bdef069..65727f7aa8 100644 --- a/kernel/trunk/docs/sysfuncs.txt +++ b/kernel/trunk/docs/sysfuncs.txt @@ -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; +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. ======= ====================================================================== diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 471d0a4660..962b4b500a 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -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 diff --git a/kernel/trunk/macros.inc b/kernel/trunk/macros.inc index 58f751db00..bcb46d6683 100644 --- a/kernel/trunk/macros.inc +++ b/kernel/trunk/macros.inc @@ -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 diff --git a/kernel/trunk/version-gen.sh b/kernel/trunk/version-gen.sh new file mode 100755 index 0000000000..c3d4708bcd --- /dev/null +++ b/kernel/trunk/version-gen.sh @@ -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