# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR The FreeBSD Project # This file is distributed under the same license as the FreeBSD Documentation package. # Vladlen Popolitov , 2025. msgid "" msgstr "" "Project-Id-Version: FreeBSD Documentation VERSION\n" "POT-Creation-Date: 2025-05-01 19:56-0300\n" "PO-Revision-Date: 2025-11-26 04:45+0000\n" "Last-Translator: Vladlen Popolitov \n" "Language-Team: Russian \n" "Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Generator: Weblate 4.17\n" #. type: Title = #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:1 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:14 #, no-wrap msgid "Kernel Objects" msgstr "Объекты ядра" #. type: YAML Front Matter: title #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:1 #, no-wrap msgid "Chapter 3. Kernel Objects" msgstr "Глава 3. Объекты ядра" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:54 msgid "" "Kernel Objects, or _Kobj_ provides an object-oriented C programming system " "for the kernel. As such the data being operated on carries the description " "of how to operate on it. This allows operations to be added and removed " "from an interface at run time and without breaking binary compatibility." msgstr "" "Объекты ядра, или _Kobj_, предоставляют объектно-ориентированную систему " "программирования на языке C для ядра. Таким образом, данные, с которыми " "производится работа, содержат описание того, как над ними следует выполнять " "операции. Это позволяет добавлять и удалять операции из интерфейса во время " "выполнения без нарушения бинарной совместимости." #. type: Title == #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:56 #, no-wrap msgid "Terminology" msgstr "Терминология" #. type: Labeled list #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:58 #, no-wrap msgid "Object" msgstr "Объект" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:60 msgid "A set of data - data structure - data allocation." msgstr "Набор данных - структура данных - аллокация данных." #. type: Labeled list #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:61 #, no-wrap msgid "Method" msgstr "Метод" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:63 msgid "An operation - function." msgstr "Операция — функция." #. type: Labeled list #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:64 #, no-wrap msgid "Class" msgstr "Класс" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:66 msgid "One or more methods." msgstr "Один или несколько методов." #. type: Labeled list #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:67 #, no-wrap msgid "Interface" msgstr "Интерфейс" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:69 msgid "A standard set of one or more methods." msgstr "Стандартный набор из одного или нескольких методов." #. type: Title == #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:71 #, no-wrap msgid "Kobj Operation" msgstr "Как работает Kobj" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:76 msgid "" "Kobj works by generating descriptions of methods. Each description holds a " "unique id as well as a default function. The description's address is used " "to uniquely identify the method within a class' method table." msgstr "" "Kobj работает путем генерации описаний методов. Каждое описание содержит " "уникальный идентификатор, а также функцию по умолчанию. Адрес описания " "используется для однозначной идентификации метода в таблице методов класса." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:85 msgid "" "A class is built by creating a method table associating one or more " "functions with method descriptions. Before use the class is compiled. The " "compilation allocates a cache and associates it with the class. A unique id " "is assigned to each method description within the method table of the class " "if not already done so by another referencing class compilation. For every " "method to be used a function is generated by script to qualify arguments and " "automatically reference the method description for a lookup. The generated " "function looks up the method by using the unique id associated with the " "method description as a hash into the cache associated with the object's " "class. If the method is not cached the generated function proceeds to use " "the class' table to find the method. If the method is found then the " "associated function within the class is used; otherwise, the default " "function associated with the method description is used." msgstr "" "Класс создается путем построения таблицы методов, связывающей одну или " "несколько функций с описаниями методов. Перед использованием класс " "компилируется. В процессе компиляции выделяется кэш и связывается с классом. " "Уникальный идентификатор назначается каждому описанию метода в таблице " "методов класса, если это ещё не было сделано другой компиляцией, ссылающейся " "на этот класс. Для каждого используемого метода скриптом генерируется " "функция для проверки аргументов и автоматического обращения к описанию " "метода для поиска. Сгенерированная функция ищет метод, используя уникальный " "идентификатор, связанный с описанием метода, в качестве хэша для доступа к " "кэшу, связанному с классом объекта. Если метод не найден в кэше, " "сгенерированная функция использует таблицу класса для поиска метода. Если " "метод найден, используется связанная с ним функция внутри класса; в " "противном случае используется функция по умолчанию, связанная с описанием " "метода." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:87 msgid "These indirections can be visualized as the following:" msgstr "Эти перенаправления можно визуализировать следующим образом:" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:91 #, no-wrap msgid "object->cache<->class\n" msgstr "object->cache<->class\n" #. type: Title == #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:94 #, no-wrap msgid "Using Kobj" msgstr "Использование Kobj" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:96 #, no-wrap msgid "Structures" msgstr "Структуры" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:101 #, no-wrap msgid "struct kobj_method\n" msgstr "struct kobj_method\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:103 #, no-wrap msgid "Functions" msgstr "Функции" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:113 #, no-wrap msgid "" "void kobj_class_compile(kobj_class_t cls);\n" "void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops);\n" "void kobj_class_free(kobj_class_t cls);\n" "kobj_t kobj_create(kobj_class_t cls, struct malloc_type *mtype, int mflags);\n" "void kobj_init(kobj_t obj, kobj_class_t cls);\n" "void kobj_delete(kobj_t obj, struct malloc_type *mtype);\n" msgstr "" "void kobj_class_compile(kobj_class_t cls);\n" "void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops);\n" "void kobj_class_free(kobj_class_t cls);\n" "kobj_t kobj_create(kobj_class_t cls, struct malloc_type *mtype, int mflags);" "\n" "void kobj_init(kobj_t obj, kobj_class_t cls);\n" "void kobj_delete(kobj_t obj, struct malloc_type *mtype);\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:115 #, no-wrap msgid "Macros" msgstr "Макросы" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:123 #, no-wrap msgid "" "KOBJ_CLASS_FIELDS\n" "KOBJ_FIELDS\n" "DEFINE_CLASS(name, methods, size)\n" "KOBJMETHOD(NAME, FUNC)\n" msgstr "" "KOBJ_CLASS_FIELDS\n" "KOBJ_FIELDS\n" "DEFINE_CLASS(name, methods, size)\n" "KOBJMETHOD(NAME, FUNC)\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:125 #, no-wrap msgid "Headers" msgstr "Заголовки" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:131 #, no-wrap msgid "" "\n" "\n" msgstr "" "\n" "\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:133 #, no-wrap msgid "Creating an Interface Template" msgstr "Создание шаблона интерфейса" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:137 msgid "" "The first step in using Kobj is to create an Interface. Creating the " "interface involves creating a template that the script [.filename]#src/sys/" "kern/makeobjops.pl# can use to generate the header and code for the method " "declarations and method lookup functions." msgstr "" "Первым шагом в использовании Kobj является создание интерфейса. Создание " "интерфейса включает в себя создание шаблона, который скрипт [.filename]#src/" "sys/kern/makeobjops.pl# может использовать для генерации заголовочного файла " "и кода объявлений методов и функций поиска методов." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:139 msgid "" "Within this template the following keywords are used: `#include`, " "`INTERFACE`, `CODE`, `EPILOG`, `HEADER`, `METHOD`, `PROLOG`, `STATICMETHOD`, " "and `DEFAULT`." msgstr "" "В этом шаблоне используются следующие ключевые слова: `#include`, `INTERFACE`" ", `CODE`, `EPILOG`, `HEADER`, `METHOD`, `PROLOG`, `STATICMETHOD` и `DEFAULT`." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:141 msgid "" "The `#include` statement and what follows it is copied verbatim to the head " "of the generated code file." msgstr "" "Включение директивы `#include` и всего, что следует за ней, копируется " "дословно в начало сгенерированного файла с кодом." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:143 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:154 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:164 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:179 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:192 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:207 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:241 msgid "For example:" msgstr "Например:" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:147 #, no-wrap msgid "#include \n" msgstr "#include \n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:152 msgid "" "The `INTERFACE` keyword is used to define the interface name. This name is " "concatenated with each method name as [interface name]_[method name]. Its " "syntax is INTERFACE [interface name];." msgstr "" "Ключевое слово `INTERFACE` используется для определения имени интерфейса. " "Это имя объединяется с каждым именем метода в формате [имя интерфейса]_[имя " "метода]. Его синтаксис: `INTERFACE [имя интерфейса];`." #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:158 #, no-wrap msgid "INTERFACE foo;\n" msgstr "INTERFACE foo;\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:162 msgid "" "The `CODE` keyword copies its arguments verbatim into the code file. Its " "syntax is `CODE { [whatever] };`" msgstr "" "Ключевое слово `CODE` копирует свои аргументы дословно в файл кода. Его " "синтаксис: `CODE { [что угодно] };`" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:173 #, no-wrap msgid "" "CODE {\n" "\tstruct foo * foo_alloc_null(struct bar *)\n" "\t{\n" "\t\treturn NULL;\n" "\t}\n" "};\n" msgstr "" "CODE {\n" "\tstruct foo * foo_alloc_null(struct bar *)\n" "\t{\n" "\t\treturn NULL;\n" "\t}\n" "};\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:177 msgid "" "The `HEADER` keyword copies its arguments verbatim into the header file. " "Its syntax is `HEADER { [whatever] };`" msgstr "" "Ключевое слово `HEADER` копирует свои аргументы в заголовочный файл без " "изменений. Его синтаксис: `HEADER { [что угодно] };`" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:186 #, no-wrap msgid "" "HEADER {\n" " struct mumble;\n" " struct grumble;\n" "};\n" msgstr "" "HEADER {\n" " struct mumble;\n" " struct grumble;\n" "};\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:190 msgid "" "The `METHOD` keyword describes a method. Its syntax is `METHOD [return " "type] [method name] { [object [, arguments]] };`" msgstr "" "Ключевое слово `METHOD` описывает метод. Его синтаксис: `METHOD [" "возвращаемый тип] [имя метода] { [объект [, аргументы]] };`" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:200 #, no-wrap msgid "" "METHOD int bar {\n" "\tstruct object *;\n" "\tstruct foo *;\n" "\tstruct bar;\n" "};\n" msgstr "" "METHOD int bar {\n" "\tstruct object *;\n" "\tstruct foo *;\n" "\tstruct bar;\n" "};\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:205 msgid "" "The `DEFAULT` keyword may follow the `METHOD` keyword. It extends the " "`METHOD` key word to include the default function for method. The extended " "syntax is `METHOD [return type] [method name] { [object; [other arguments]] }" "DEFAULT [default function];`" msgstr "" "Ключевое слово `DEFAULT` может следовать за ключевым словом `METHOD`. Оно " "расширяет ключевое слово `METHOD`, включая функцию по умолчанию для метода. " "Расширенный синтаксис выглядит так: `METHOD [тип возвращаемого значения] [" "имя метода] { [объект; [другие аргументы]] } DEFAULT [функция по умолчанию];`" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:215 #, no-wrap msgid "" "METHOD int bar {\n" "\tstruct object *;\n" "\tstruct foo *;\n" "\tint bar;\n" "} DEFAULT foo_hack;\n" msgstr "" "METHOD int bar {\n" "\tstruct object *;\n" "\tstruct foo *;\n" "\tint bar;\n" "} DEFAULT foo_hack;\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:220 msgid "" "The `STATICMETHOD` keyword is used like the `METHOD` keyword except the kobj " "data is not at the head of the object structure so casting to kobj_t would " "be incorrect. Instead `STATICMETHOD` relies on the Kobj data being " "referenced as 'ops'. This is also useful for calling methods directly out " "of a class's method table." msgstr "" "Ключевое слово `STATICMETHOD` используется аналогично ключевому слову " "`METHOD`, за исключением того, что данные kobj не находятся в начале " "структуры объекта, поэтому приведение к типу kobj_t было бы некорректным. " "Вместо этого `STATICMETHOD` полагается на то, что данные Kobj указаны как " "'ops'. Это также полезно для вызова методов напрямую из таблицы методов " "класса." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:223 msgid "" "The `PROLOG` and `EPILOG` keywords sets inserts code immediately before or " "directly after the `METHOD` they are attached to. This feature is used " "primarily for profiling situations where it's difficult to obtain the " "information in another way." msgstr "" "Ключевые слова `PROLOG` и `EPILOG` вставляют код непосредственно перед или " "сразу после `METHOD`, к которому они прикреплены. Эта функция в основном " "используется для профилирования в ситуациях, когда сложно получить " "информацию другим способом." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:225 msgid "Other complete examples:" msgstr "Другие полные примеры:" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:230 #, no-wrap msgid "" "src/sys/kern/bus_if.m\n" "src/sys/kern/device_if.m\n" msgstr "" "src/sys/kern/bus_if.m\n" "src/sys/kern/device_if.m\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:232 #, no-wrap msgid "Creating a Class" msgstr "Создание класса" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:239 msgid "" "The second step in using Kobj is to create a class. A class consists of a " "name, a table of methods, and the size of objects if Kobj's object handling " "facilities are used. To create the class use the macro `DEFINE_CLASS()`. " "To create the method table create an array of kobj_method_t terminated by a " "NULL entry. Each non-NULL entry may be created using the macro " "`KOBJMETHOD()`." msgstr "" "Второй шаг в использовании Kobj — это создание класса. Класс состоит из " "имени, таблицы методов и размера объектов, если используются средства " "обработки объектов Kobj. Для создания класса используйте макрос " "`DEFINE_CLASS()`. Чтобы создать таблицу методов, создайте массив элементов " "kobj_method_t, завершающийся записью NULL. Каждую не-NULL запись можно " "создать с помощью макроса `KOBJMETHOD()`." #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:245 #, no-wrap msgid "DEFINE_CLASS(fooclass, foomethods, sizeof(struct foodata));\n" msgstr "DEFINE_CLASS(fooclass, foomethods, sizeof(struct foodata));\n" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:251 #, no-wrap msgid "" "kobj_method_t foomethods[] = {\n" "\tKOBJMETHOD(bar_doo, foo_doo),\n" "\tKOBJMETHOD(bar_foo, foo_foo),\n" "\t{ NULL, NULL}\n" "};\n" msgstr "" "kobj_method_t foomethods[] = {\n" "\tKOBJMETHOD(bar_doo, foo_doo),\n" "\tKOBJMETHOD(bar_foo, foo_foo),\n" "\t{ NULL, NULL}\n" "};\n" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:256 msgid "" "The class must be \"compiled\". Depending on the state of the system at the " "time that the class is to be initialized a statically allocated cache, \"ops " "table\" have to be used. This can be accomplished by declaring a `struct " "kobj_ops` and using `kobj_class_compile_static();` otherwise, " "`kobj_class_compile()` should be used." msgstr "" "Класс должен быть \"скомпилирован\". В зависимости от состояния системы на " "момент инициализации класса, необходимо использовать статически выделенный " "кэш, \"таблицу операций\". Это может быть достигнуто путем объявления `" "struct kobj_ops` и использования `kobj_class_compile_static();` в противном " "случае следует использовать `kobj_class_compile()`." #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:257 #, no-wrap msgid "Creating an Object" msgstr "Создание объекта" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:263 msgid "" "The third step in using Kobj involves how to define the object. Kobj object " "creation routines assume that Kobj data is at the head of an object. If " "this in not appropriate you will have to allocate the object yourself and " "then use `kobj_init()` on the Kobj portion of it; otherwise, you may use " "`kobj_create()` to allocate and initialize the Kobj portion of the object " "automatically. `kobj_init()` may also be used to change the class that an " "object uses." msgstr "" "Третий шаг в использовании Kobj связан с определением объекта. Процедуры " "создания объекта Kobj предполагают, что данные Kobj находятся в начале " "объекта. Если это не подходит, вам придется самостоятельно выделить память " "для объекта, а затем использовать `kobj_init()` для части объекта, " "относящейся к Kobj; в противном случае вы можете использовать `kobj_create()`" " для автоматического выделения и инициализации части объекта, относящейся к " "Kobj. `kobj_init()` также может использоваться для изменения класса, " "который использует объект." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:265 msgid "To integrate Kobj into the object you should use the macro KOBJ_FIELDS." msgstr "Для интеграции Kobj в объект следует использовать макрос `KOBJ_FIELDS`." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:267 msgid "For example" msgstr "Например" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:275 #, no-wrap msgid "" "struct foo_data {\n" "\tKOBJ_FIELDS;\n" "\tfoo_foo;\n" "\tfoo_bar;\n" "};\n" msgstr "" "struct foo_data {\n" "\tKOBJ_FIELDS;\n" "\tfoo_foo;\n" "\tfoo_bar;\n" "};\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:277 #, no-wrap msgid "Calling Methods" msgstr "Вызов методов" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:282 msgid "" "The last step in using Kobj is to simply use the generated functions to use " "the desired method within the object's class. This is as simple as using " "the interface name and the method name with a few modifications. The " "interface name should be concatenated with the method name using a '_' " "between them, all in upper case." msgstr "" "Последним шагом в использовании Kobj является простое использование " "сгенерированных функций для вызова нужного метода в классе объекта. Это так " "же просто, как использование имени интерфейса и имени метода с небольшими " "изменениями. Имя интерфейса должно быть соединено с именем метода с " "использованием символа '_' между ними, все в верхнем регистре." #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:284 msgid "" "For example, if the interface name was foo and the method was bar then the " "call would be:" msgstr "" "Например, если имя интерфейса было foo, а метод — bar, то вызов будет " "выглядеть следующим образом:" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:288 #, no-wrap msgid "[return value = ] FOO_BAR(object [, other parameters]);\n" msgstr "[return value = ] FOO_BAR(object [, other parameters]);\n" #. type: Title === #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:290 #, no-wrap msgid "Cleaning Up" msgstr "Очистка" #. type: Plain text #: documentation/content/en/books/arch-handbook/kobj/_index.adoc:292 msgid "" "When an object allocated through `kobj_create()` is no longer needed " "`kobj_delete()` may be called on it, and when a class is no longer being " "used `kobj_class_free()` may be called on it." msgstr "" "Когда объект, выделенный через `kobj_create()`, больше не нужен, можно " "вызвать для него `kobj_delete()`, а когда класс больше не используется, " "можно вызвать для него `kobj_class_free()`."