Compare commits
462 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce9d95e4e8 | |||
| c0254bca6d | |||
| 30e01ba560 | |||
| af79958f1a | |||
| eca55dfed8 | |||
| 0b75cd9c2a | |||
| 24367a58ae | |||
| f40c4a6630 | |||
| 7ad283d36a | |||
| e630f89547 | |||
| 34eeedcbcf | |||
| 90ab346195 | |||
| 5ce583fdd8 | |||
| c2f660f885 | |||
| 80af9c93fb | |||
| 8b678be2b7 | |||
| ef92ba670b | |||
| 6f4d3b57f9 | |||
| dd39e93194 | |||
| 275cbbe7b3 | |||
| 290ed59d0b | |||
| 3e51197ae4 | |||
| 3d49f0abf6 | |||
| 391bba92a6 | |||
| e96c13ff70 | |||
| 9ef117cbc6 | |||
| af95af6f3a | |||
| d2fd6654eb | |||
| 3fcc0f8964 | |||
| 327e29791e | |||
| f24b962e2b | |||
| 40e4faad90 | |||
| f4c35a09de | |||
| 42d84be2c3 | |||
| 28c00fd9ed | |||
| 379950fb45 | |||
| 4292149567 | |||
| 030c16d29e | |||
| 29e9d2ff11 | |||
| 24b2182bec | |||
| a8cfac3c1f | |||
| 654a3165c0 | |||
| c8544ad6a4 | |||
| 61e6954265 | |||
| 237bfcefb3 | |||
| b7c32fc102 | |||
| 2ec77db77a | |||
| 7ce609fddc | |||
| 75abb84f25 | |||
| f066dd2ad9 | |||
| 1197797ee1 | |||
| 45f75bd00d | |||
| 163e83009d | |||
| ecf5907f83 | |||
| 78c1ff4bd4 | |||
| c82c13417d | |||
| d50d997d6e | |||
| f35abd187b | |||
| a1071d50ef | |||
| 24499a20e9 | |||
| 266f527d2a | |||
| 122551ab45 | |||
| 6b077ccfac | |||
| 452aa40770 | |||
| c82779f1af | |||
| bf59ccd0f4 | |||
| aafa26ea38 | |||
| 3fc0ba78ca | |||
| a50c1a892f | |||
| 08d87ea439 | |||
| c37fbf6f40 | |||
| 34319442aa | |||
| dde6e6bc9e | |||
| 07d603f47a | |||
| df0a3701aa | |||
| 459d73b4e7 | |||
| 8578f078c6 | |||
| 20091b196f | |||
| b7f85b9500 | |||
| 83d4beb33d | |||
| 63314a8363 | |||
| 23f2a036e7 | |||
| cd6f876fa8 | |||
| 954f6342ec | |||
| 55b5eb8cee | |||
| 24ebe9647c | |||
| ee2c0ebd88 | |||
| 1cbc7519c9 | |||
| 16b905625d | |||
| 707c0e408b | |||
| dc5a30573c | |||
| 28276bf565 | |||
| 3ed59b6f55 | |||
| d6c4dc3184 | |||
| 86e046d080 | |||
| 760667e00f | |||
| f7fee4ca9b | |||
| 4e35a1682f | |||
| b7c82d7333 | |||
| 7972ddeac7 | |||
| 394695784b | |||
| 8b6a72af3e | |||
| ef6ef96576 | |||
| 87a796b440 | |||
| 2cd03ccfe0 | |||
| 90487afffc | |||
| 96ee8198f8 | |||
| a872442aa3 | |||
| eb74fae1fd | |||
| bb8bb799f9 | |||
| 537c3a70bb | |||
| 8266274e84 | |||
| 3f2756ccf4 | |||
| af77072301 | |||
| e23c434cc6 | |||
| 16c416cbea | |||
| 7c9e0fea03 | |||
| 4275002414 | |||
| c5a62dda05 | |||
| fb0323c8ce | |||
| a007e4e4c7 | |||
| b0f7ceec1b | |||
| d90e7ff02b | |||
| fb559d6f1b | |||
| c17153318c | |||
| f515c44eb3 | |||
| 8f6ff5a59a | |||
| e5370dff36 | |||
| 2fcce9360c | |||
| 63d36004b3 | |||
| ca3c769467 | |||
| 6c36106666 | |||
| 974d37a25d | |||
| 935b36d24b | |||
| 5dd4418ffd | |||
| dbbdb907aa | |||
| 0576463aea | |||
| 681238c7c3 | |||
| 8bdc44bb10 | |||
| 046761c1b6 | |||
| b0b1ae50e5 | |||
| a9cd9db8c6 | |||
| 523cf39b5a | |||
| 8891ed7d7a | |||
| 116f4a50f7 | |||
| db050db01c | |||
| 1acec3e7b3 | |||
| 3ae9258347 | |||
| e7c0334ac0 | |||
| a9d84f3a5d | |||
| 3e03f1e6fd | |||
| 9f63a93d63 | |||
| 97eedf450d | |||
| 19e8ad309f | |||
| e19354a9ee | |||
| bd3c8fb4fe | |||
| 2198df5576 | |||
| 09f0d145d0 | |||
| b9244ab96b | |||
| ef1ae0f3c7 | |||
| 20db826dd4 | |||
| dd8853af00 | |||
| 8ad4e45b50 | |||
| bfe30f797a | |||
| 136dd11069 | |||
| 4e9d0ebaf2 | |||
| 36b08c2d86 | |||
| 8adfe8d887 | |||
| 6ca621d506 | |||
| cf0001fca6 | |||
| 6aa814f30a | |||
| d630fd55f7 | |||
| 09aa9a6a39 | |||
| d8d2b9cb69 | |||
| 32b8bd898c | |||
| 79489757e3 | |||
| cc4eed7788 | |||
| 998ffd2c29 | |||
| 0fb3a8d5b2 | |||
| b955065ee1 | |||
| df347f51c0 | |||
| 84fbca5798 | |||
| 8e9b86476c | |||
| c19da29ab7 | |||
| 7c166e73a3 | |||
| 1c4fd2c388 | |||
| 2a123f6986 | |||
| fc36a1dad0 | |||
| e6c733a881 | |||
| 913deff2d4 | |||
| d193fa1ced | |||
| 62db896e48 | |||
| cd74fd521c | |||
| bc5f3c2b2a | |||
| fa15355071 | |||
| 16a27a022f | |||
| 0fcd132e85 | |||
| 25c8a1049b | |||
| 25c1c2c6fb | |||
| 40fac6e194 | |||
| 95ec1d8a33 | |||
| a650fb9c62 | |||
| 0d0cec9420 | |||
| 188f42e531 | |||
| 464448c711 | |||
| 0d99f26430 | |||
| 81c482e377 | |||
| 3bb21bb0f0 | |||
| af1389233d | |||
| 3b1f5b2ebe | |||
| 3e16bc81a9 | |||
| 59d9bcb596 | |||
| e926850ce3 | |||
| 7a8ce1066a | |||
| ac3dd9922a | |||
| 8faf044d1d | |||
| d14425d84a | |||
| 3f982e8034 | |||
| dbaa4c51f8 | |||
| 2abf5120a3 | |||
| 1afad50078 | |||
| 32192829ff | |||
| 9dfebdf827 | |||
| 2a06eb791a | |||
| 20323ba64e | |||
| c9038205db | |||
| 8c3f30a4f7 | |||
| 4f99b6217f | |||
| 5a84cd5e44 | |||
| b6403ff571 | |||
| b5eccd40cf | |||
| 6e48298534 | |||
| 5aa2f21253 | |||
| debc7302c2 | |||
| 3c3bcd692f | |||
| 2fee354b4b | |||
| 54d755e3d2 | |||
| 917e6a82ff | |||
| 0ecda4d40c | |||
| 2a4822eca3 | |||
| 065e0dbf7c | |||
| e6162ba762 | |||
| d5ee2e927a | |||
| ec37cda9c0 | |||
| d2e25b94a4 | |||
| 53ec90e8b4 | |||
| d5bc9a96ca | |||
| 06e4eaf17c | |||
| 0d3d5530bf | |||
| ae86834d4c | |||
| b91a267fe3 | |||
| 88fdb850dd | |||
| 510a2c0e73 | |||
| 4f650b3704 | |||
| e9264f925a | |||
| 0414e3922c | |||
| 679b943e0e | |||
| 2d5e3ad41f | |||
| 48ac939566 | |||
| 60873784d2 | |||
| f643e11212 | |||
| e654600c27 | |||
| d499a07b0f | |||
| 918b00e43d | |||
| 3d3c713828 | |||
| 55932ce89e | |||
| a572db52fd | |||
| 3f73b8d8a0 | |||
| 0965669f4b | |||
| 565df959b1 | |||
| 45376a2bb3 | |||
| de9daa4a85 | |||
| 8e1424fbec | |||
| 79f150a3d5 | |||
| b61655b9de | |||
| 3cf8ae04f1 | |||
| 25b4a34f1b | |||
| b1f3169310 | |||
| 26daf96b90 | |||
| 206d0ebf05 | |||
| a64ce2f81d | |||
| 5aaddd467c | |||
| 0fd6bec4a3 | |||
| c1cc7e366a | |||
| 442e9f33bf | |||
| 1d3d48feb8 | |||
| f24814450d | |||
| 5a461aabb0 | |||
| 5e5b9ba370 | |||
| 47f0ee965a | |||
| dfbf5915dd | |||
| 4d69a58225 | |||
| d021526210 | |||
| df8936cad0 | |||
| 5c2b1dbebd | |||
| 8119074390 | |||
| 4c6db2dd87 | |||
| 4dca2d8b87 | |||
| fce63282fb | |||
| 4a0e344edd | |||
| e17b350248 | |||
| 453644d57e | |||
| a33d35f47f | |||
| 259697608f | |||
| e9d1cf9187 | |||
| 36aa392534 | |||
| cef88432a1 | |||
| 4e07800428 | |||
| 7e78df36cf | |||
| f6a1ab4012 | |||
| 29776a2fa3 | |||
| e485a40d3d | |||
| 9d0819ae02 | |||
| 3b533bd964 | |||
| 41928ad25b | |||
| 9189d79fb7 | |||
| 66bedb903f | |||
| e53b0056d2 | |||
| 3a56fb41d5 | |||
| 4e0c9d5cd5 | |||
| 7ef9fd2f2d | |||
| 821135d686 | |||
| 1e4a43e0f2 | |||
| ef4bd71aca | |||
| 334bf4a5eb | |||
| f70e7df1c5 | |||
| a7ca9f90d6 | |||
| 6ed5794b1e | |||
| 69d5939542 | |||
| 38ce67f426 | |||
| dfd6ba9a28 | |||
| 9e8bcb7690 | |||
| 630e80f724 | |||
| b61cfe0fb2 | |||
| 6606d5708f | |||
| b78d09fc24 | |||
| 942072d72f | |||
| 2047ab7b8a | |||
| 1e4a1f5852 | |||
| 50264d439f | |||
| 245f434aa4 | |||
| 0130725518 | |||
| 096183c27d | |||
| bfce80fef8 | |||
| ae6451e138 | |||
| 5751b60430 | |||
| f2b0348eb4 | |||
| 6c1745964d | |||
| 561524d440 | |||
| d9df8fd01c | |||
| 144dfb1bab | |||
| 0b8885f8d1 | |||
| 62d89ca38e | |||
| 0f9175e11c | |||
| c31a678075 | |||
| ca2d8e27f4 | |||
| 91af18b5a6 | |||
| e7f77a88f1 | |||
| 80b28a8768 | |||
| cb33ec1875 | |||
| 1b2bc49d41 | |||
| 73147816c7 | |||
| b83f5f7ec4 | |||
| 5c75019ddd | |||
| bef162cd24 | |||
| 2944f5cc43 | |||
| 41990c570f | |||
| f9334b25ed | |||
| 30637c3a51 | |||
| f95c361283 | |||
| df1c5352c4 | |||
| 455c555223 | |||
| b1285a4658 | |||
| d19e1845f8 | |||
| 4a29a27204 | |||
| ac9b627fad | |||
| 2461d82431 | |||
| 181d1d69cb | |||
| 5673102fd4 | |||
| c6906d4f2d | |||
| 47276eb503 | |||
| 81a0abed20 | |||
| 1ebc74f31f | |||
| 7c4a4ac0ba | |||
| 2226eebdc8 | |||
| 5ca3cec48e | |||
| 74dbffcb8d | |||
| 44e588b586 | |||
| 8018ecd274 | |||
| 913e7bf0b7 | |||
| 3db113f2d7 | |||
| 642284d3fb | |||
| 61e5eaa99a | |||
| 43f03e44dd | |||
| 60ed18dd80 | |||
| f7b951cb72 | |||
| a72f8e6b75 | |||
| 5f59da0e13 | |||
| a6f0f8768c | |||
| 177e325d89 | |||
| 8a826f0472 | |||
| 3013442c9d | |||
| 0ca6e9627f | |||
| 32a1425294 | |||
| b8b4feeedd | |||
| 151404d0d3 | |||
| 11f485cf77 | |||
| a0dbeb1527 | |||
| 33c02fe570 | |||
| fe13f087c9 | |||
| 73ef08dc11 | |||
| 7d74ab6bce | |||
| ef90d20604 | |||
| ae56fd09fa | |||
| 0949f75054 | |||
| df1ef59063 | |||
| f53100453f | |||
| 69f3cc6b88 | |||
| 4715809f96 | |||
| 43d34814bf | |||
| f6090319c7 | |||
| b48d2ad54a | |||
| 4c8ce44426 | |||
| f6eb4f8138 | |||
| 9d8e700fc6 | |||
| 1df4d8748f | |||
| ac3141a6d8 | |||
| d0a0f338c7 | |||
| ca4250c663 | |||
| f8da589298 | |||
| 36242acdb0 | |||
| f7297e3ded | |||
| 04bf7b9e3b | |||
| 60a56e1139 | |||
| 7a78333bae | |||
| 37465c2d2f | |||
| f2032f0bf4 | |||
| 50ad329b6e | |||
| 28981a82d0 | |||
| c9d7026293 | |||
| f43bce08d6 | |||
| c4e76f027d | |||
| a968c1bd6d | |||
| 064136703c | |||
| 18a2fd9baa | |||
| 0c6a38e189 | |||
| 5263b115bf | |||
| b01eccca2e | |||
| 6fd063984a | |||
| bc2623ce99 | |||
| c16a750251 | |||
| c673fb9351 | |||
| 25ffb602ea | |||
| 552e2a073f | |||
| c0e5808656 | |||
| 9368b0d6eb | |||
| 3bfa61d189 | |||
| d9fd3b1646 | |||
| 14d64d25d3 | |||
| dbeed54f2b | |||
| 07bd4d7901 | |||
| 614d3dfd62 |
+12
-11
@@ -11,23 +11,24 @@
|
||||
---
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: true
|
||||
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AlignOperands: AlignAfterOperator
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
@@ -52,7 +53,7 @@ BreakConstructorInitializersBeforeComma: false
|
||||
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 80
|
||||
ColumnLimit: 0
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
#CompactNamespaces: false # Unknown to clang-format-4.0
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
@@ -463,7 +464,7 @@ SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp03
|
||||
Standard: Auto
|
||||
TabWidth: 4
|
||||
UseTab: Always
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
symbol-file ./mentos/kernel.bin
|
||||
exec-file ./mentos/kernel.bin
|
||||
target remote localhost:1234
|
||||
@@ -0,0 +1,86 @@
|
||||
name: Ubuntu
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- "releases/**"
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
- ".gitignore"
|
||||
- "**/macos.yml"
|
||||
- "**/windows.yml"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
- ".gitignore"
|
||||
- "**/macos.yml"
|
||||
- "**/windows.yml"
|
||||
jobs:
|
||||
doxygen:
|
||||
name: Doxygen
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y doxygen nasm
|
||||
- name: Generate documentation
|
||||
run: |
|
||||
cmake -B build -D DOXYGEN_WARN_AS_ERROR=NO
|
||||
cmake --build build --target mentos_documentation
|
||||
build:
|
||||
name: Build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: [
|
||||
# You can access the following values via ${{ matrix.??? }}
|
||||
#
|
||||
# pkgs : apt-get package names. It can include multiple package names which are delimited by space.
|
||||
# cc : C compiler executable.
|
||||
# cxx : C++ compiler executable for `make ctocpptest`.
|
||||
# x32 : Set 'true' if compiler supports x32. Otherwise, set 'false'.
|
||||
# Set 'fail' if it supports x32 but fails for now. 'fail' cases must be removed.
|
||||
# x86 : Set 'true' if compiler supports x86 (-m32). Otherwise, set 'false'.
|
||||
# Set 'fail' if it supports x86 but fails for now. 'fail' cases must be removed.
|
||||
# cxxtest : Set 'true' if it can be compiled as C++ code. Otherwise, set 'false'.
|
||||
# freestanding : Set 'true' if it can be compiled and execute freestanding code. Otherwise, set 'false'.
|
||||
# Usually, it requires Linux, x86_64 and gcc/g++.
|
||||
# os : GitHub Actions YAML workflow label. See https://github.com/actions/virtual-environments#available-environments
|
||||
# gcc
|
||||
{ pkgs: "nasm", cc: gcc, cxx: g++, os: ubuntu-latest },
|
||||
{ pkgs: "gcc-12 g++-12 nasm", cc: gcc-12, cxx: g++-12, os: ubuntu-22.04 },
|
||||
{ pkgs: "gcc-11 g++-11 nasm", cc: gcc-11, cxx: g++-11, os: ubuntu-22.04 },
|
||||
{ pkgs: "gcc-10 g++-10 nasm", cc: gcc-10, cxx: g++-10, os: ubuntu-22.04 },
|
||||
{ pkgs: "gcc-9 g++-9 nasm", cc: gcc-9, cxx: g++-9, os: ubuntu-22.04 },
|
||||
{ pkgs: "gcc-8 g++-8 nasm", cc: gcc-8, cxx: g++-8, os: ubuntu-20.04 },
|
||||
{ pkgs: "gcc-7 g++-7 nasm", cc: gcc-7, cxx: g++-7, os: ubuntu-20.04 },
|
||||
# clang
|
||||
{ pkgs: "nasm", cc: clang, cxx: clang++, os: ubuntu-latest },
|
||||
{ pkgs: "clang-14 nasm", cc: clang-14, cxx: clang++-14, os: ubuntu-22.04 },
|
||||
{ pkgs: "clang-13 nasm", cc: clang-13, cxx: clang++-13, os: ubuntu-22.04 },
|
||||
{ pkgs: "clang-12 nasm", cc: clang-12, cxx: clang++-12, os: ubuntu-22.04 },
|
||||
{ pkgs: "clang-11 nasm", cc: clang-11, cxx: clang++-11, os: ubuntu-22.04 },
|
||||
{ pkgs: "clang-10 nasm", cc: clang-10, cxx: clang++-10, os: ubuntu-20.04 },
|
||||
{ pkgs: "clang-9 nasm", cc: clang-9, cxx: clang++-9, os: ubuntu-20.04 },
|
||||
{ pkgs: "clang-8 nasm", cc: clang-8, cxx: clang++-8, os: ubuntu-20.04 },
|
||||
{ pkgs: "clang-7 nasm", cc: clang-7, cxx: clang++-7, os: ubuntu-20.04 },
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
# Set environment variables
|
||||
env:
|
||||
# We globally set CC and CXX.
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ${{ matrix.pkgs }}
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -B build
|
||||
cmake --build build --parallel 2
|
||||
+21
@@ -1,3 +1,15 @@
|
||||
# Covers Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
@@ -99,3 +111,12 @@ src/initscp/initfscp
|
||||
|
||||
# OS generated files
|
||||
.DS_Store
|
||||
|
||||
# OS filesystem files.
|
||||
files/bin/**
|
||||
|
||||
# ISO creation files.
|
||||
iso/boot/*.bin
|
||||
|
||||
# ClangD stuff.
|
||||
.cache
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
dist : xenial
|
||||
sudo : required
|
||||
language : c
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-5
|
||||
env: COMPILER=gcc-5
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq nasm
|
||||
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DCMAKE_C_COMPILER=$COMPILER .. && make
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "gdb",
|
||||
"request": "attach",
|
||||
"name": "(gdb) Attach",
|
||||
"target": "localhost:1234",
|
||||
"remote": true,
|
||||
"cwd": "${workspaceRoot}/build",
|
||||
"valuesFormatting": "parseText"
|
||||
}
|
||||
]
|
||||
}
|
||||
+236
-80
@@ -1,111 +1,267 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# =============================================================================
|
||||
# PROJECT SETUP
|
||||
# =============================================================================
|
||||
|
||||
# Set the minimum required version of cmake.
|
||||
cmake_minimum_required(VERSION 3.1...3.22)
|
||||
|
||||
# Initialize the project.
|
||||
project(MentOs)
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
project(mentos C ASM)
|
||||
|
||||
message(STATUS "Crosscompiling: ${CMAKE_CROSSCOMPILING}")
|
||||
# Set the default build type to Debug.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Setting build type to 'Debug' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# OS-SPECIFIC COMPILERS SETUP
|
||||
# =============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add operating system specific option.
|
||||
message(STATUS "System name: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
message(STATUS "Kernel version: ${CMAKE_SYSTEM_VERSION}")
|
||||
if ((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE)
|
||||
# Apple MacOSx
|
||||
elseif ((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32)
|
||||
# Windows
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
message(STATUS "Crosscompiling : ${CMAKE_CROSSCOMPILING}")
|
||||
message(STATUS "System name : ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
message(STATUS "Kernel version : ${CMAKE_SYSTEM_VERSION}")
|
||||
if((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE)
|
||||
# Specify the linker flags.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||
elseif((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32)
|
||||
# Windows set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
else()
|
||||
# Generic Unix System
|
||||
find_program(LSB_RELEASE_EXEC lsb_release)
|
||||
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release
|
||||
# Generic Unix System.
|
||||
# Find the `lsb_release` program.
|
||||
find_program(LSB_RELEASE_EXEC lsb_release HINTS /usr/bin/ /usr/local/bin/)
|
||||
# Mark the program path as advanced, we do not want it to appear as an option.
|
||||
mark_as_advanced(LSB_RELEASE_EXEC)
|
||||
# Get the version.
|
||||
execute_process(
|
||||
COMMAND "${LSB_RELEASE_EXEC}" --short --release
|
||||
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "LSB version: ${LSB_RELEASE_VERSION_SHORT}")
|
||||
if (${LSB_RELEASE_VERSION_SHORT} MATCHES "^18")
|
||||
# Ubuntu 18
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
elseif (${LSB_RELEASE_VERSION_SHORT} MATCHES "^19")
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
message(STATUS "LSB version : ${LSB_RELEASE_VERSION_SHORT}")
|
||||
if(${LSB_RELEASE_VERSION_SHORT} MATCHES "^18")
|
||||
# Ubuntu 18 set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^19")
|
||||
# Ubuntu 19
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
||||
elseif (${LSB_RELEASE_VERSION_SHORT} MATCHES "^20")
|
||||
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^20")
|
||||
# Ubuntu 20
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
||||
else()
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
# set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||
endif()
|
||||
# Speicfy the linker.
|
||||
set(CMAKE_LINKER ld)
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the debugging option.
|
||||
set(DEBUGGING_TYPE "DEBUG_STDIO" CACHE STRING
|
||||
"Chose the type of debugging: DEBUG_STDIO DEBUG_LOG")
|
||||
set_property(
|
||||
CACHE DEBUGGING_TYPE PROPERTY STRINGS
|
||||
DEBUG_STDIO
|
||||
DEBUG_LOG)
|
||||
if ("${DEBUGGING_TYPE}" STREQUAL "DEBUG_STDIO" OR
|
||||
"${DEBUGGING_TYPE}" STREQUAL "DEBUG_LOG")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${DEBUGGING_TYPE}")
|
||||
message(STATUS "Setting debugging type to ${DEBUGGING_TYPE}.")
|
||||
else ()
|
||||
message(FATAL_ERROR "Debugging type ${DEBUGGING_TYPE} is not valid.")
|
||||
endif ()
|
||||
# =============================================================================
|
||||
# ASSEMBLY COMPILER
|
||||
# =============================================================================
|
||||
|
||||
# Find the NASM compiler.
|
||||
find_program(ASM_COMPILER NAMES nasm HINTS /usr/bin/ /usr/local/bin/)
|
||||
# Mark the variable ASM_COMPILER as advanced.
|
||||
mark_as_advanced(ASM_COMPILER)
|
||||
# Check that we have found the compiler.
|
||||
if(NOT ASM_COMPILER)
|
||||
message(FATAL_ERROR "ASM compiler not found!")
|
||||
endif(NOT ASM_COMPILER)
|
||||
# Set the asm compiler.
|
||||
set(CMAKE_ASM_COMPILER ${ASM_COMPILER})
|
||||
# Set the assembly compiler flags.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -f elf -g -O0 -F dwarf -o <OBJECT> <SOURCE>")
|
||||
else()
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -f elf -g -O3 -o <OBJECT> <SOURCE>")
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# GLOBAL COMPILATION FLAGS
|
||||
# =============================================================================
|
||||
|
||||
# Warning flags.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
|
||||
# Disable some specific warnings.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-braces")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument")
|
||||
|
||||
# Set the compiler options.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-pic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
|
||||
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
# Set the assembly compiler flags.
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32")
|
||||
|
||||
# =============================================================================
|
||||
# SUB-DIRECTORIES SETUP
|
||||
# =============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the sub-directories.
|
||||
add_subdirectory(programs)
|
||||
add_subdirectory(programs/tests)
|
||||
add_subdirectory(mentos)
|
||||
add_subdirectory(initscp)
|
||||
add_subdirectory(libc)
|
||||
add_subdirectory(doc)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Generate the initrd filesystem.
|
||||
add_custom_target(
|
||||
initfs
|
||||
COMMAND echo "---------------------------------------------"
|
||||
COMMAND echo "Initializing 'initfs'..."
|
||||
COMMAND echo "---------------------------------------------"
|
||||
COMMAND ./initscp/initfscp -s ${CMAKE_SOURCE_DIR}/files -t ${CMAKE_BINARY_DIR}/initfs -m /dev
|
||||
COMMAND echo "---------------------------------------------"
|
||||
COMMAND echo "Done!"
|
||||
COMMAND echo "---------------------------------------------"
|
||||
DEPENDS initfscp
|
||||
# =============================================================================
|
||||
# FILESYSTEM
|
||||
# =============================================================================
|
||||
|
||||
# MentOS is compatible with EXT2 fileystems. This target generates an EXT2
|
||||
# fileystem using the content of the `files` folder.
|
||||
add_custom_target(filesystem
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/rootfs.img
|
||||
COMMAND echo '============================================================================='
|
||||
COMMAND echo 'Creating EXT2 filesystem...'
|
||||
COMMAND echo '============================================================================='
|
||||
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/files/proc
|
||||
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/files/dev
|
||||
COMMAND mke2fs -L 'rootfs' -N 0 -d ${CMAKE_SOURCE_DIR}/files -b 4096 -m 5 -r 1 -t ext2 -v -F ${CMAKE_BINARY_DIR}/rootfs.img 32M
|
||||
COMMAND echo '============================================================================='
|
||||
COMMAND echo 'Done!'
|
||||
COMMAND echo '============================================================================='
|
||||
DEPENDS programs tests
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Set memory size.
|
||||
SET(MEMORY_SIZE 1096M)
|
||||
# =============================================================================
|
||||
# EMULATION SERIAL OUTPUT OPTION
|
||||
# =============================================================================
|
||||
# Set the list of valid emulator output options.
|
||||
set(EMULATOR_OUTPUT_TYPES OUTPUT_STDIO OUTPUT_LOG)
|
||||
# Add the emulator output option.
|
||||
set(EMULATOR_OUTPUT_TYPE "OUTPUT_STDIO" CACHE STRING "Chose the type of emulator output: ${EMULATOR_OUTPUT_TYPES}")
|
||||
# List of emulator output options.
|
||||
set_property(CACHE EMULATOR_OUTPUT_TYPE PROPERTY STRINGS ${EMULATOR_OUTPUT_TYPES})
|
||||
# Check which emulator output option is currently active.
|
||||
list(FIND EMULATOR_OUTPUT_TYPES ${EMULATOR_OUTPUT_TYPE} INDEX)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR "Emulator output type ${EMULATOR_OUTPUT_TYPE} is not valid.")
|
||||
else()
|
||||
message(STATUS "Setting emulator output type to ${EMULATOR_OUTPUT_TYPE}.")
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Builds the code and runs qemu with the built Os.
|
||||
SET(EMULATOR qemu-system-i386)
|
||||
if (${DEBUGGING_TYPE} STREQUAL DEBUG_LOG)
|
||||
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial file:serial.log)
|
||||
elseif (${DEBUGGING_TYPE} STREQUAL DEBUG_STDIO)
|
||||
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial stdio)
|
||||
endif ()
|
||||
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -vga std)
|
||||
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -k it)
|
||||
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -m ${MEMORY_SIZE})
|
||||
SET(EMULATOR_KERNEL -kernel mentos/kernel.bin)
|
||||
SET(EMULATOR_FS -initrd initfs)
|
||||
# =============================================================================
|
||||
# EMULATOR CONFIGURATION
|
||||
# =============================================================================
|
||||
|
||||
# Set the emulator.
|
||||
set(EMULATOR qemu-system-i386)
|
||||
# Set the debug type.
|
||||
if(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial file:${CMAKE_BINARY_DIR}/serial.log)
|
||||
elseif(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_STDIO)
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial stdio)
|
||||
endif(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
|
||||
# Set the type of video.
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -vga std)
|
||||
# Set the amount of memory.
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -m 1096M)
|
||||
# Set the EXT2 drive.
|
||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -drive file=${CMAKE_BINARY_DIR}/rootfs.img,format=raw,index=0,media=disk)
|
||||
|
||||
# =============================================================================
|
||||
# Booting with QEMU for fun
|
||||
# =============================================================================
|
||||
|
||||
# This first target runs the emulator passing the kernel binary file.
|
||||
add_custom_target(
|
||||
qemu
|
||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} ${EMULATOR_KERNEL} ${EMULATOR_FS}
|
||||
DEPENDS MentOs
|
||||
DEPENDS initfs
|
||||
COMMAND test -e ${CMAKE_BINARY_DIR}/rootfs.img || ${CMAKE_COMMAND} -E cmake_echo_color --red "No filesystem file detected, you need to run: make filesystem"
|
||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -kernel ${CMAKE_BINARY_DIR}/mentos/bootloader.bin
|
||||
DEPENDS bootloader.bin
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Builds the code and runs qemu with the built Os.
|
||||
SET(EMULATOR_FLAGS_GDB ${EMULATOR_FLAGS} -s -S)
|
||||
SET(GDB_PROG cgdb)
|
||||
SET(GDB_ARGS -x ${CMAKE_SOURCE_DIR}/.gdb.debug)
|
||||
# =============================================================================
|
||||
# Booting with QEMU+GDB for debugging
|
||||
# =============================================================================
|
||||
|
||||
# First, we need to generate a GDB file containing all the symbols of all our
|
||||
# executables.
|
||||
add_custom_target(
|
||||
gdbinit
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/gdb.run
|
||||
# Create the generic gdb configuration.
|
||||
COMMAND echo "add-symbol-file ${CMAKE_BINARY_DIR}/mentos/kernel.bin" > ${CMAKE_BINARY_DIR}/gdb.run
|
||||
COMMAND echo "add-symbol-file ${CMAKE_BINARY_DIR}/mentos/bootloader.bin" >> ${CMAKE_BINARY_DIR}/gdb.run
|
||||
COMMAND find ${CMAKE_SOURCE_DIR}/files/bin -type f | xargs realpath | sed 's/^/add-symbol-file /' >> ${CMAKE_BINARY_DIR}/gdb.run
|
||||
COMMAND echo "break boot.c: boot_main" >> ${CMAKE_BINARY_DIR}/gdb.run
|
||||
COMMAND echo "break kernel.c: kmain" >> ${CMAKE_BINARY_DIR}/gdb.run
|
||||
# Create the GDB connection file.
|
||||
COMMAND echo "target remote localhost:1234" >> ${CMAKE_BINARY_DIR}/gdb.run
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/mentos/bootloader.bin
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/mentos/kernel.bin
|
||||
DEPENDS programs
|
||||
DEPENDS tests
|
||||
DEPENDS libc
|
||||
)
|
||||
|
||||
# This second target runs the emualtor passing the kernel binary file, and also
|
||||
# the `-s -S` options. This basically tells the emulator to run the kernel in
|
||||
# debug mode, and pause it up until a debugger connects to it.
|
||||
add_custom_target(
|
||||
qemu-gdb
|
||||
COMMAND xterm -geometry 160x30-0-0 -e ${EMULATOR} ${EMULATOR_FLAGS_GDB} ${EMULATOR_KERNEL} ${EMULATOR_FS} &
|
||||
COMMAND xterm -geometry 160x30-0+0 -e ${GDB_PROG} ${GDB_ARGS} &
|
||||
DEPENDS MentOs
|
||||
DEPENDS initfs
|
||||
COMMAND test -e ${CMAKE_BINARY_DIR}/rootfs.img || ${CMAKE_COMMAND} -E cmake_echo_color --red "No filesystem file detected, you need to run: make filesystem"
|
||||
COMMAND echo ""
|
||||
COMMAND echo "Now, QEMU has loaded the kernel, and it is waiting that you"
|
||||
COMMAND echo "remotely connect to it. To start debugging, open a new shell"
|
||||
COMMAND echo "in THIS same folder, and just type:"
|
||||
COMMAND echo " gdb --quiet --command=gdb.run"
|
||||
COMMAND echo "or if you want to use cgdb, type:"
|
||||
COMMAND echo " cgdb --quiet --command=gdb.run"
|
||||
COMMAND echo ""
|
||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -s -S -kernel ${CMAKE_BINARY_DIR}/mentos/bootloader.bin
|
||||
DEPENDS bootloader.bin
|
||||
DEPENDS gdbinit
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# Booting with QEMU+GRUB
|
||||
# =============================================================================
|
||||
|
||||
# First, we need to build the ISO for the cdrom.
|
||||
add_custom_target(
|
||||
cdrom.iso
|
||||
COMMAND cp -rf ${CMAKE_SOURCE_DIR}/iso .
|
||||
COMMAND cp ${CMAKE_BINARY_DIR}/mentos/bootloader.bin ${CMAKE_BINARY_DIR}/iso/boot
|
||||
COMMAND grub-mkrescue -o ${CMAKE_BINARY_DIR}/cdrom.iso ${CMAKE_BINARY_DIR}/iso
|
||||
DEPENDS bootloader.bin
|
||||
)
|
||||
|
||||
# This third target runs the emualtor, but this time, the kernel binary file is
|
||||
# inside the cdrom, so we will not pass the `-kernel` option. We will pass the
|
||||
# `-cdrom` option and the `-boot d` option, all the other options will remain
|
||||
# the same.
|
||||
add_custom_target(
|
||||
qemu-grub
|
||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -boot d -cdrom ${CMAKE_BINARY_DIR}/cdrom.iso
|
||||
DEPENDS cdrom.iso
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
Code Styles for this project
|
||||
============================
|
||||
|
||||
|
||||
If you'd like to contribute you are welcome, thus refer to the following coding
|
||||
styles please:
|
||||
|
||||
* **C**: _the Linux kernel coding style_
|
||||
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Alessandro Danese, Enrico Fraccaroli, Luigi Capogrosso,
|
||||
Mirco De Marchi
|
||||
Copyright (c) 2014-2024 MentOs-Team.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,139 +1,356 @@
|
||||
MentOS
|
||||
======
|
||||
# MentOS (Mentoring Operating System)
|
||||
|
||||
[](https://forthebadge.com)
|
||||
[](https://forthebadge.com)
|
||||
[](https://forthebadge.com)
|
||||
|
||||
What is MentOS
|
||||
-----------------
|
||||
[](https://github.com/mentos-team/MentOS/actions/workflows/ubuntu.yml)
|
||||
|
||||
MentOS (Mentoring Operating system) is an open source educational operating
|
||||
system.
|
||||
The goal of MentOS is to provide a project environment that is realistic
|
||||
enough to show how a real Operating System work, yet simple enough that
|
||||
students can understand and modify it in significant ways.
|
||||
## Table of Contents
|
||||
|
||||
There are so many operating systems, why did we write MentOS?
|
||||
It is true, there are a lot of education operating system, BUT
|
||||
how many of them follow the guideline defined by Linux?
|
||||
- [MentOS (Mentoring Operating System)](#mentos-mentoring-operating-system)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [What is MentOS](#what-is-mentos)
|
||||
- [Implemented features](#implemented-features)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Installing the prerequisites](#installing-the-prerequisites)
|
||||
- [Compiling MentOS](#compiling-mentos)
|
||||
- [Generating the EXT2 filesystem](#generating-the-ext2-filesystem)
|
||||
- [Running MentOS](#running-mentos)
|
||||
- [Running MentOS from GRUB](#running-mentos-from-grub)
|
||||
- [Running and adding new programs to MentOS](#running-and-adding-new-programs-to-mentos)
|
||||
- [Create a new program](#create-a-new-program)
|
||||
- [Add the new program to the list of compiled sources](#add-the-new-program-to-the-list-of-compiled-sources)
|
||||
- [Running a program or a test](#running-a-program-or-a-test)
|
||||
- [Kernel logging](#kernel-logging)
|
||||
- [Change the scheduling algorithm](#change-the-scheduling-algorithm)
|
||||
- [Debugging the kernel](#debugging-the-kernel)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
## What is MentOS
|
||||
|
||||
MentOS (Mentoring Operating System) is an open source educational operating
|
||||
system. The goal of MentOS is to provide a project environment that is realistic
|
||||
enough to show how a real Operating System work, yet simple enough that students
|
||||
can understand and modify it in significant ways.
|
||||
|
||||
There are so many operating systems, why did we write MentOS? It is true, there
|
||||
are a lot of education operating system, BUT how many of them follow the
|
||||
guideline de fined by Linux?
|
||||
|
||||
MentOS aims to have the same Linux's data structures and algorithms. It has a
|
||||
well-documented source code, and you can compile it on your laptop in a few
|
||||
seconds!
|
||||
|
||||
MentOS aims to have the same Linux's data structures and algorithms. It
|
||||
has a well-documented source code, and you can compile it on your laptop
|
||||
in a few seconds!
|
||||
If you are a beginner in Operating-System developing, perhaps MentOS is the
|
||||
right operating system to start with.
|
||||
|
||||
Parts of MentOS are inherited or inspired by a similar educational operating
|
||||
system called [DreamOs](https://github.com/dreamos82/DreamOs) written by Ivan
|
||||
Gualandri.
|
||||
|
||||
Developers
|
||||
----------------
|
||||
Main Developers:
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
* [Enrico Fraccaroli](https://github.com/Galfurian)
|
||||
* [Alessandro Danese](https://github.com/alessandroDanese88)
|
||||
* [Luigi Capogrosso](https://github.com/luigicapogrosso)
|
||||
* [Mirco De Marchi](https://github.com/mircodemarchi)
|
||||
## Implemented features
|
||||
|
||||
Prerequisites
|
||||
-----------------
|
||||
Follows the list of implemented features:
|
||||
|
||||
MentOS is compatible with the main Unix distribution operating systems. It has been tested with *Ubuntu* and *MacOS*, but specifically tested on *Ubuntu 18.04*.
|
||||
**Processes and Events**
|
||||
- [x] Memory protection (User vs Kernel);
|
||||
- [x] Processes;
|
||||
- [x] Scheduler (synchronous and asynchronous);
|
||||
- [x] Interrupts and Exceptions;
|
||||
- [x] Signals;
|
||||
- [x] Timers and RTC;
|
||||
- [x] Wait-queues;
|
||||
- [x] System Calls;
|
||||
- [ ] Multi-core;
|
||||
|
||||
**Memory**
|
||||
- [x] Paging;
|
||||
- [x] Buddy System;
|
||||
- [x] Slab Allocation;
|
||||
- [x] Zone Allocator;
|
||||
- [x] Cache Allocator;
|
||||
- [x] Heap;
|
||||
- [x] Virtual Addressing;
|
||||
|
||||
For compiling the main system:
|
||||
**Filesystem**
|
||||
- [x] Virtual Filesystem (VFS);
|
||||
- [x] Initramfs;
|
||||
- [x] EXT2;
|
||||
- [x] Procfs;
|
||||
|
||||
* nasm
|
||||
* gcc
|
||||
* g++
|
||||
* make
|
||||
* cmake
|
||||
* git
|
||||
**Input/Output**
|
||||
- [x] Programmable Interrupt Controller (PIC) drivers;
|
||||
- [x] Keyboard drivers (IT/ENG layouts);
|
||||
- [x] Video drivers;
|
||||
- [ ] VGA drivers;
|
||||
|
||||
To run and try:
|
||||
**Inter-Process Communication (IPC)**
|
||||
- [X] Semaphore
|
||||
- [ ] Message queue
|
||||
- [ ] Shared memory
|
||||
- [ ] Named pipe
|
||||
|
||||
* qemu-system-i386
|
||||
I will try to keep it updated...
|
||||
|
||||
For debugging:
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
* ccmake
|
||||
* cgdb
|
||||
* xterm
|
||||
## Prerequisites
|
||||
|
||||
For MacOS, you have additional dependencies:
|
||||
MentOS is compatible with the main **unix-based** operating systems. It has been
|
||||
tested with *Ubuntu*, and under Windows with *WSL1* and *WSL2*.
|
||||
|
||||
* i386-elf-binutils (from [i386-elf-toolchain](https://github.com/nativeos/homebrew-i386-elf-toolchain))
|
||||
* i386-elf-gcc (from [i386-elf-toolchain](https://github.com/nativeos/homebrew-i386-elf-toolchain))
|
||||
For **compiling** the system we need:
|
||||
|
||||
Prerequisites installation commands
|
||||
-----------------
|
||||
- git
|
||||
- gcc
|
||||
- nasm
|
||||
- make
|
||||
- cmake
|
||||
- ccmake (suggested)
|
||||
- e2fsprogs (should be already installed)
|
||||
|
||||
For Ubuntu:
|
||||
Under **MacOS**, for compiling, you have additional dependencies:
|
||||
|
||||
```
|
||||
- i386-elf-binutils
|
||||
- i386-elf-gcc
|
||||
|
||||
For **executing** the operating system we need:
|
||||
|
||||
- qemu-system-i386 (or qemu-system-x86)
|
||||
|
||||
For **debugging** we suggest using:
|
||||
|
||||
- gdb or cgdb
|
||||
|
||||
### Installing the prerequisites
|
||||
|
||||
Under **Ubuntu**, you can type the following commands:
|
||||
|
||||
```bash
|
||||
sudo apt-get update && sudo apt-get upgrade -y
|
||||
sudo apt-get install -y build-essential git cmake qemu-system-i386
|
||||
sudo apt-get install -y cgdb xterm #<- for debug only
|
||||
sudo apt-get install -y git build-essential nasm make cmake cmake-curses-gui e2fsprogs
|
||||
sudo apt-get install -y qemu-system-x86
|
||||
sudo apt-get install -y gdb cgdb
|
||||
```
|
||||
Note: Older versions might have `qemu-system-i386` instead of `qemu-system-x86`.
|
||||
|
||||
For MacOS:
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
You need to install additionally the i386-elf cross-compiler. The simplest installation method is through Homebrew package manager. Install [Homebrew](https://brew.sh/index_it) if you don't already have and exec the following commands:
|
||||
## Compiling MentOS
|
||||
|
||||
```
|
||||
brew update && brew upgrade
|
||||
brew tap nativeos/i386-elf-toolchain
|
||||
brew install i386-elf-binutils i386-elf-gcc git cmake qemu nasm
|
||||
brew install cgdb xterm #<- for debug only
|
||||
```
|
||||
Compile MentOS with:
|
||||
|
||||
Compiling MentOS
|
||||
-----------------
|
||||
Compile and boot MentOS with qemu in Unix systems:
|
||||
|
||||
```
|
||||
```bash
|
||||
cd <clone_directory>
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Generating the EXT2 filesystem
|
||||
|
||||
Generate the EXT2 filesystem with:
|
||||
|
||||
```bash
|
||||
make filesystem
|
||||
```
|
||||
you just need to generate the filesystem once. If you change a `program` you need to re-generate the entire filesystem with `make filesystem`, but this will override any changes you made to the files inside the `rootfs.img`. In the future I will find a way to update just the `/usr/bin` directory and the programs.
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Running MentOS
|
||||
|
||||
Boot MentOS with qemu:
|
||||
|
||||
```bash
|
||||
make qemu
|
||||
```
|
||||
|
||||
If you want to access to the shell, use one of the usernames listed in files/passwd.
|
||||
To login, use one of the usernames listed in `files/etc/passwd`.
|
||||
|
||||
**For MacOS**, the steps are the same but instead of `cmake ..`, you have to put an additional argument in order to use the i386-elf cross-compiler:
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
```
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake ..
|
||||
## Running MentOS from GRUB
|
||||
|
||||
For booting MentOS from GRUB in QEMU we need the following tools:
|
||||
|
||||
- xorriso
|
||||
- grub-mkrescue (from grub-common)
|
||||
|
||||
We also need `grub-pc-bin`, otherwise GRUB won't start in QEMU.
|
||||
|
||||
Which can be installed in Ubuntu with the following command:
|
||||
```bash
|
||||
sudo apt-get update && sudo apt-get upgrade -y
|
||||
sudo apt-get install -y grub-common grub-pc-bin xorriso
|
||||
```
|
||||
|
||||
Change the scheduling algorithm
|
||||
-----------------
|
||||
|
||||
MentOS provides three different scheduling algorithms:
|
||||
|
||||
* Round-Robin
|
||||
* Priority
|
||||
* Completely Fair Scheduling
|
||||
|
||||
If you want to change the scheduling algorithm:
|
||||
Boot MentOS with qemu through GRUB by calling:
|
||||
|
||||
```bash
|
||||
make qemu-grub
|
||||
```
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Running and adding new programs to MentOS
|
||||
|
||||
This section explains how to add a new program to MentOS, and also how to run programs in mentos. It also explains how to add new tests, which are located in the `programs/tests` folder.
|
||||
|
||||
### Create a new program
|
||||
|
||||
Head to the `programs` (or the `programs/tests`) folder. Create and open a new program, for instance a file called `hello_world.c`, with your preferred editor, and add this content to the file:
|
||||
```C
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Hello, World!\n\n");
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### Add the new program to the list of compiled sources
|
||||
Now we can add the program to the list of files which are compiled and placed inside MentOS filesystem.
|
||||
The following procedure is the same for both `programs` and `programs/tests`, what changes is which `CMakeLists.txt` file we modify.
|
||||
|
||||
You need to modify the `CMakeLists.txt` file, either `programs/CMakeLists.txt` or `programs/tests/CMakeLists.txt`, and add your program to the list of files to be compiled:
|
||||
```Makefile
|
||||
# Add the executables (manually).
|
||||
set(PROGRAMS
|
||||
init.c
|
||||
...
|
||||
hello_world.c
|
||||
)
|
||||
```
|
||||
or
|
||||
```Makefile
|
||||
# Add the executables (manually).
|
||||
set(TESTS
|
||||
t_mem.c
|
||||
...
|
||||
hello_world.c
|
||||
)
|
||||
```
|
||||
|
||||
That's it, the `hello_world.c` file will be compiled and will appear inside the `/bin` or `/bin/tests` folder of MentOS.
|
||||
|
||||
### Running a program or a test
|
||||
Once you login into MentOS, if you placed your source code in `programs`, you can execute the program by simply typing:
|
||||
```bash
|
||||
hello_world
|
||||
```
|
||||
because the file resides in `/bin`, and that folder is listed in the `PATH` environment variable.
|
||||
|
||||
Now, if you placed your source code inside the `programs/tests` folder, the executable will end up inside the `/bin/tests` folder.
|
||||
However, the `/bin/tests` folder is not listed in `PATH`, so, if you want to execute a test from that folder you need to specify the full path:
|
||||
```bash
|
||||
/bin/tests/hello_world
|
||||
```
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Kernel logging
|
||||
The kernel provides ways of printing logging messages *from* inside the kernel code *to* the bash where you executed the `make qemu`.
|
||||
|
||||
These *logging* functions are:
|
||||
```C
|
||||
#define pr_emerg(...)
|
||||
#define pr_alert(...)
|
||||
#define pr_crit(...)
|
||||
#define pr_err(...)
|
||||
#define pr_warning(...)
|
||||
#define pr_notice(...)
|
||||
#define pr_info(...)
|
||||
#define pr_debug(...)
|
||||
#define pr_default(...)
|
||||
```
|
||||
|
||||
You use them like you would use a `printf`:
|
||||
```C
|
||||
if (fd < 0) {
|
||||
pr_err("Failed to open file '%s', received file descriptor %d.\n", filename, fd);
|
||||
return 1;
|
||||
}
|
||||
```
|
||||
|
||||
By default only message that goes from `pr_notice` included down to `pr_emerg` are displayed.
|
||||
|
||||
Each logging function (they are actually macros) is a wrapper that automatically sets the desired **log level**. Each log level is identified by a number, and declared as follows:
|
||||
```C
|
||||
#define LOGLEVEL_DEFAULT (-1) ///< default-level messages.
|
||||
#define LOGLEVEL_EMERG 0 ///< system is unusable.
|
||||
#define LOGLEVEL_ALERT 1 ///< action must be taken immediately.
|
||||
#define LOGLEVEL_CRIT 2 ///< critical conditions.
|
||||
#define LOGLEVEL_ERR 3 ///< error conditions.
|
||||
#define LOGLEVEL_WARNING 4 ///< warning conditions.
|
||||
#define LOGLEVEL_NOTICE 5 ///< normal but significant condition.
|
||||
#define LOGLEVEL_INFO 6 ///< informational.
|
||||
#define LOGLEVEL_DEBUG 7 ///< debug-level messages.
|
||||
```
|
||||
|
||||
You can change the logging level by including the following lines at the beginning of your source code:
|
||||
```C
|
||||
// Include the kernel log levels.
|
||||
#include "sys/kernel_levels.h"
|
||||
/// Change the header.
|
||||
#define __DEBUG_HEADER__ "[ATA ]"
|
||||
/// Set the log level.
|
||||
#define __DEBUG_LEVEL__ LOGLEVEL_INFO
|
||||
// Include the debuggin header.
|
||||
#include "io/debug.h"
|
||||
```
|
||||
This example sets the `__DEBUG_LEVEL__`, so that all the messages from `INFO` and below are shown. While `__DEBUG_HEADER__` is just a string that is automatically prepended to your message, helping you identifying from which code the message is coming from.
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Change the scheduling algorithm
|
||||
|
||||
MentOS supports scheduling algorithms for aperiodic:
|
||||
|
||||
- Round-Robin (RR)
|
||||
- Highest Priority
|
||||
- Completely Fair Scheduling (CFS)
|
||||
- Aperiodic Earliest Deadline First (AEDF)
|
||||
|
||||
It also supports periodic algorithms:
|
||||
|
||||
- Earliest Deadline First (EDF)
|
||||
- Rate Monotonic (RM)
|
||||
|
||||
If you want to change the scheduling algorithm, to Round-Robin (RR) for instance:
|
||||
|
||||
```bash
|
||||
cd build
|
||||
|
||||
# Round Robin scheduling algorithm
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_RR ..
|
||||
# Priority scheduling algorithm
|
||||
make
|
||||
make qemu
|
||||
```
|
||||
|
||||
or you can activate one of the others:
|
||||
|
||||
```bash
|
||||
# Highest Priority
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_PRIORITY ..
|
||||
# Completely Fair Scheduling algorithm
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_CFS ..
|
||||
|
||||
make
|
||||
make qemu
|
||||
# Completely Fair Scheduling (CFS)
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_CFS ..
|
||||
# Earliest Deadline First (EDF)
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_EDF ..
|
||||
# Rate Monotonic (RM)
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_RM ..
|
||||
# Aperiodic Earliest Deadline First (AEDF)
|
||||
cmake -DSCHEDULER_TYPE=SCHEDULER_AEDF ..
|
||||
```
|
||||
|
||||
Otherwise you can use `ccmake`:
|
||||
|
||||
```
|
||||
```bash
|
||||
cd build
|
||||
cmake ..
|
||||
ccmake ..
|
||||
@@ -150,82 +367,102 @@ ENABLE_BUDDY_SYSTEM OFF
|
||||
SCHEDULER_TYPE SCHEDULER_RR
|
||||
```
|
||||
|
||||
Select SCHEDULER_TYPE, and type Enter to scroll the three available algorithms
|
||||
(SCHEDULER_RR, SCHEDULER_PRIORITY, SCHEDULER_CFS).
|
||||
Afterwards,
|
||||
```
|
||||
type c
|
||||
type g
|
||||
Select SCHEDULER_TYPE, and type Enter to scroll the three available algorithms (SCHEDULER_RR, SCHEDULER_PRIORITY, SCHEDULER_CFS, SCHEDULER_EDF, SCHEDULER_RM, SCHEDULER_AEDF). Afterwards, you need to
|
||||
|
||||
```bash
|
||||
<press c>
|
||||
<press g>
|
||||
make
|
||||
make qemu
|
||||
```
|
||||
|
||||
Enable to Buddy System
|
||||
-----------------
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
MentOS provides a Buddy System to manage the allocation and deallocation of
|
||||
page frames in the physical memory.
|
||||
## Debugging the kernel
|
||||
|
||||
If you want to enable the MentOS's Buddy System:
|
||||
If you want to use GDB to debug MentOS, first you need to compile everything:
|
||||
|
||||
```
|
||||
cd build
|
||||
cmake -DENABLE_BUDDY_SYSTEM=ON ..
|
||||
make
|
||||
make qemu
|
||||
```
|
||||
|
||||
Otherwise you can use `ccmake`:
|
||||
|
||||
```
|
||||
cd build
|
||||
cmake ..
|
||||
ccmake ..
|
||||
```
|
||||
|
||||
Now you should see something like this:
|
||||
|
||||
```
|
||||
BUILD_DOCUMENTATION ON
|
||||
CMAKE_BUILD_TYPE
|
||||
CMAKE_INSTALL_PREFIX /usr/local
|
||||
DEBUGGING_TYPE DEBUG_STDIO
|
||||
ENABLE_BUDDY_SYSTEM OFF
|
||||
SCHEDULER_TYPE SCHEDULER_RR
|
||||
```
|
||||
|
||||
Select ENABLE_BUDDY_SYSTEM, and type Enter.
|
||||
You should see something like this:
|
||||
```
|
||||
BUILD_DOCUMENTATION ON
|
||||
CMAKE_BUILD_TYPE
|
||||
CMAKE_INSTALL_PREFIX /usr/local
|
||||
DEBUGGING_TYPE DEBUG_STDIO
|
||||
ENABLE_BUDDY_SYSTEM ON
|
||||
SCHEDULER_TYPE SCHEDULER_RR
|
||||
```
|
||||
|
||||
Afterwards,
|
||||
```
|
||||
type c
|
||||
type g
|
||||
make
|
||||
make qemu
|
||||
```
|
||||
|
||||
Use Debugger
|
||||
-----------------
|
||||
If you want to use GDB to debug MentOS:
|
||||
```
|
||||
```bash
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
Then, you need to generate a file called `.gdbinit` placed inside the `build` directory, which will tell **gdb** which *object* file he needs to read in order to allow proper debugging. Basically, it provides for each binary file, the location of their `.text` section. To generate the file, just execute:
|
||||
```bash
|
||||
make gdbinit
|
||||
```
|
||||
|
||||
Finally, you run qemu in debugging mode with:
|
||||
```bash
|
||||
make qemu-gdb
|
||||
```
|
||||
|
||||
If you did everything correctly, you should have 3 windows with:
|
||||
If you did everything correctly, you should see an empty QEMU window. Basically, QEMU is waiting for you to connect *remotely* with gdb. Anyway, running `make qemu-gdb` will make your current shell busy, you cannot call `gdb` in it. You need to open a new shell inside the `build` folder and do a:
|
||||
```bash
|
||||
gdb --quiet --command=gdb.run
|
||||
```
|
||||
1) - Kernel Booting on qemu
|
||||
2) - Shell with video printing of statistics previously discussed
|
||||
3) - Debugger cgdb with code screening
|
||||
or
|
||||
```bash
|
||||
cgdb --quiet --command=gdb.run
|
||||
```
|
||||
|
||||
Now you should have in front of you:
|
||||
1. the QEMU window waiting for you;
|
||||
2. the **first** shell where you ran `make qemu-gdb`, which is also waiting for you;
|
||||
3. the **second** shell where `gdb` is runnign and, you guessed it, is waiting for you.
|
||||
|
||||
By default I placed a breakpoint at the begginning of (1) the *bootloader* and (2) the *kernel* itself.
|
||||
|
||||
So, when gdb starts you need to first give a continue:
|
||||
```bash
|
||||
(gdb) continue
|
||||
```
|
||||
|
||||
This will make the kernel run, and stop at the **first** breakpoint which is inside the *bootloader*:
|
||||
```bash
|
||||
Breakpoint 1, boot_main (...) at .../mentos/src/boot.c:220
|
||||
220 {
|
||||
```
|
||||
|
||||
giving a second `continue` will get you to the start of the operating system:
|
||||
|
||||
This will make the kernel run, and stop at the **second** breakpoint which is inside the *kernel*:
|
||||
```bash
|
||||
Breakpoint 2, kmain (...) at .../mentos/src/kernel.c:95
|
||||
95 {
|
||||
```
|
||||
|
||||
There is also a launch configuration for vscode in `.vscode/launch.json`, called `(gdb) Attach`, which should allow you
|
||||
to connect to the running process.
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
## Contributors
|
||||
|
||||
Project Manager:
|
||||
|
||||
* [Enrico Fraccaroli](https://github.com/Galfurian)
|
||||
|
||||
Developers:
|
||||
* [Alessandro Danese](https://github.com/alessandroDanese88), [Luigi Capogrosso](https://github.com/luigicapogrosso), [Mirco De Marchi](https://github.com/mircodemarchi)
|
||||
- Protection ring
|
||||
- libc
|
||||
* Andrea Cracco
|
||||
- Buddy System, Heap, Paging, Slab, Caching, Zone
|
||||
- Process Image, ELF
|
||||
- VFS: procfs
|
||||
- Bootloader
|
||||
* Linda Sacchetto, Marco Berti
|
||||
- Real time scheduler
|
||||
* Daniele Nicoletti, Filippo Ziche
|
||||
- Real time scheduler (Asynchronous EDF)
|
||||
- Soft IRQs
|
||||
- Timer
|
||||
- Signals
|
||||
* And many other valuable contributors
|
||||
* [rouseabout](https://github.com/rouseabout)
|
||||
* [seekbytes](https://github.com/seekbytes)
|
||||
* [fischerling](https://github.com/fischerling)
|
||||
|
||||
*[Back to the Table of Contents](#table-of-contents)*
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: /home/enrico/Repositories/University/DreamOs/doc
|
||||
# It was generated by CMake: /usr/bin/cmake
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=/home/enrico/Repositories/University/DreamOs/doc
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=5
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.5
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
||||
@@ -0,0 +1,299 @@
|
||||
# Find Doxygen
|
||||
find_package(Doxygen)
|
||||
|
||||
if (DOXYGEN_FOUND)
|
||||
# Read the file with the version.
|
||||
file(READ ${CMAKE_SOURCE_DIR}/mentos/inc/version.h version_file)
|
||||
# Extract the OS version.
|
||||
string(REGEX MATCH "OS_MAJOR_VERSION ([0-9]*)" _ ${version_file})
|
||||
set(OS_MAJOR_VERSION ${CMAKE_MATCH_1})
|
||||
string(REGEX MATCH "OS_MINOR_VERSION ([0-9]*)" _ ${version_file})
|
||||
set(OS_MINOR_VERSION ${CMAKE_MATCH_1})
|
||||
string(REGEX MATCH "OS_MICRO_VERSION ([0-9]*)" _ ${version_file})
|
||||
set(OS_MICRO_VERSION ${CMAKE_MATCH_1})
|
||||
# Setup the Doxygen documentation.
|
||||
set(DOXYGEN_PROJECT_NAME "MentOS")
|
||||
set(DOXYGEN_PROJECT_NUMBER "${OS_MAJOR_VERSION}.${OS_MINOR_VERSION}.${OS_MICRO_VERSION}")
|
||||
set(DOXYGEN_PROJECT_BRIEF "The Mentoring Operating System")
|
||||
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_SOURCE_DIR}/README.md)
|
||||
set(DOXYGEN_IMAGE_PATH ${CMAKE_SOURCE_DIR}/doc/resources)
|
||||
set(DOXYGEN_SHOW_INCLUDE_FILES NO)
|
||||
set(DOXYGEN_GENERATE_TREEVIEW NO)
|
||||
set(DOXYGEN_WARN_NO_PARAMDOC YES)
|
||||
|
||||
set(DOXYGEN_ENABLE_PREPROCESSING YES)
|
||||
set(DOXYGEN_EXTRACT_STATIC YES)
|
||||
set(DOXYGEN_MACRO_EXPANSION YES)
|
||||
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
|
||||
set(DOXYGEN_PREDEFINED "__attribute__((x))= _syscall0= _syscall0(x)= _syscall1(x)= _syscall2(x)= _syscall3(x)=")
|
||||
|
||||
set(DOXYGEN_WARN_FORMAT "$file($line): $text")
|
||||
set(DOXYGEN_HTML_STYLESHEET ${CMAKE_SOURCE_DIR}/doc/doxygen.css)
|
||||
doxygen_add_docs(
|
||||
mentos_documentation
|
||||
${CMAKE_SOURCE_DIR}/README.md
|
||||
${CMAKE_SOURCE_DIR}/LICENSE.md
|
||||
${CMAKE_SOURCE_DIR}/doc/signal.md
|
||||
${CMAKE_SOURCE_DIR}/doc/syscall.md
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/boot.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/descriptor_tables/gdt.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/descriptor_tables/idt.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/descriptor_tables/isr.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/descriptor_tables/tss.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/devices/fpu.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/devices/pci.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/ata/ata.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/ata/ata_types.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/fdc.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/keyboard/keyboard.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/keyboard/keymap.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/mouse.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/ps2.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/drivers/rtc.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/elf/elf.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/fs/ext2.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/fs/ioctl.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/fs/procfs.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/fs/vfs.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/fs/vfs_types.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/hardware/cpuid.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/hardware/pic8259.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/hardware/timer.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/proc_modules.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_font.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_mode.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_palette.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/io/video.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/kernel.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/compiler.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/hashmap.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/irqflags.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/list.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/list_head.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/mutex.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/ndtree.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/rbtree.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/spinlock.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/stack_helper.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/klib/stdatomic.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/link_access.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/buddysystem.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/gfp.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/kheap.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/paging.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/slab.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/vmem_map.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/mem/zone_allocator.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/multiboot.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/process/prio.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/process/process.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/process/scheduler.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/process/wait.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/proc_access.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/errno.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/ipc.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/module.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/reboot.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/types.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/sys/utsname.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/system/panic.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/system/printk.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/system/signal.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/system/syscall.h
|
||||
${CMAKE_SOURCE_DIR}/mentos/inc/version.h
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/boot.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/exception.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/gdt.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/idt.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/interrupt.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/tss.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/devices/fpu.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/devices/pci.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/ata.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/fdc.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/keyboard/keyboard.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/keyboard/keymap.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/mouse.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/ps2.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/drivers/rtc.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/elf/elf.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/ext2.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/ioctl.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/namei.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/open.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/procfs.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/readdir.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/read_write.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/stat.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/fs/vfs.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/hardware/cpuid.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/hardware/pic8259.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/hardware/timer.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/debug.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/mm_io.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/proc_running.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/proc_system.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/proc_video.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/stdio.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/vga/vga.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/io/video.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/ipc/msg.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/ipc/sem.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/ipc/shm.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/kernel/sys.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/kernel.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/assert.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/ctype.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/fcvt.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/hashmap.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/libgen.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/list.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/math.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/mutex.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/ndtree.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/rbtree.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/spinlock.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/strerror.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/string.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/time.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/vscanf.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/klib/vsprintf.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/buddysystem.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/kheap.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/paging.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/slab.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/vmem_map.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/mem/zone_allocator.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/multiboot.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/process/process.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/process/scheduler.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/process/scheduler_algorithm.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/process/wait.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/sys/module.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/sys/utsname.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/system/errno.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/system/panic.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/system/printk.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/system/signal.c
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/system/syscall.c
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/boot.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/exception.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/gdt.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/idt.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/interrupt.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/tss.S
|
||||
${CMAKE_SOURCE_DIR}/mentos/src/process/user.S
|
||||
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/array.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/assert.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/bits/ioctls.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/bits/stat.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/bits/termios-struct.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ctype.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/fcntl.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/fcvt.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/grp.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/io/ansi_colors.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/io/debug.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/io/mm_io.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/io/port_io.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ipc/ipc.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ipc/msg.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ipc/sem.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ipc/shm.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/libgen.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/limits.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/math.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/pwd.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/ring_buffer.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sched.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/signal.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stdarg.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stdbool.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stddef.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stdint.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stdio.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/stdlib.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/strerror.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/string.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/bitops.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/dirent.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/errno.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/ioctl.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/kernel_levels.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/reboot.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/stat.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/types.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/unistd.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/utsname.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/sys/wait.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/system/syscall_types.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/termios.h
|
||||
${CMAKE_SOURCE_DIR}/libc/inc/time.h
|
||||
|
||||
${CMAKE_SOURCE_DIR}/libc/src/abort.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/assert.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/ctype.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/fcvt.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/grp.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/io/debug.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/io/mm_io.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/ipc/ipc.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/libc_start.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/libgen.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/math.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/pwd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sched.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/setenv.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/stdio.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/stdlib.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/strerror.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/string.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/errno.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/ioctl.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/unistd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/utsname.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/termios.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/time.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/chdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/close.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/creat.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/exec.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/exit.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/fork.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getcwd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getdents.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getppid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getsid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getuid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/interval.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/kill.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/lseek.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/mkdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/nice.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/open.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/read.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/reboot.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/rmdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setpgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setsid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setuid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/signal.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/stat.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/unlink.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/waitpid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/write.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/vscanf.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/vsprintf.c
|
||||
|
||||
${CMAKE_SOURCE_DIR}/libc/src/crt0.S
|
||||
)
|
||||
endif (DOXYGEN_FOUND)
|
||||
@@ -1,17 +0,0 @@
|
||||
* * *
|
||||
### Come usare lo script per generare un'entry di GRUB #
|
||||
* * *
|
||||
|
||||
#### 1. Inserire la partizione dei sorgenti
|
||||
Questo significa dire al programma in quale partizione si trova la vostra directory dei sorgenti.
|
||||
Ad esempio se siete su **/dev/hda2**, dovrete inserire **hda2**
|
||||
|
||||
#### 2. Inserire il mountpoint
|
||||
Tale partizione ha un mountpoint (se non lo conoscete, date da shell il comando mount senza argomenti oppure date uno sguardo in **/etc/fstab**). Ad esempio potrà essere **/** o anche **/home/vostroutente** se tenete la home directory in una partizione separata.
|
||||
|
||||
#### 3. Attenzione al path
|
||||
Il path dell'immagine di MentOS sarà calcolato automaticamente, ma per fare questo lo script dev'essere nella stessa directory dell'immagine.
|
||||
Dopodiché vi basta confermare ed avere la vostra entry nel file **menu.lst**
|
||||
|
||||
**ATTENZIONE: Usatelo solo se sapete cosa state facendo. Lo script e' stato testato e funziona, ma non rispondiamo di eventuali blocchi del vostro computer.**
|
||||
|
||||
+1912
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
@@ -0,0 +1,105 @@
|
||||
|
||||
#define KEY_LEFT_WIN 0xE05b
|
||||
#define KEY_RIGHT_WIN 0xE05c
|
||||
|
||||
Normal Shifted Ctrl Alt
|
||||
KEY_A 0x001E A 0x1E61 0x1E41 0x1E01 0x1E00
|
||||
KEY_B 0x0030 B 0x3062 0x3042 0x3002 0x3000
|
||||
KEY_C 0x002E C 0x2E63 0x2E42 0x2E03 0x2E00
|
||||
KEY_D 0x0020 D 0x2064 0x2044 0x2004 0x2000
|
||||
KEY_E 0x0012 E 0x1265 0x1245 0x1205 0x1200
|
||||
KEY_F 0x0021 F 0x2166 0x2146 0x2106 0x2100
|
||||
KEY_G 0x0022 G 0x2267 0x2247 0x2207 0x2200
|
||||
KEY_H 0x0023 H 0x2368 0x2348 0x2308 0x2300
|
||||
KEY_I 0x0017 I 0x1769 0x1749 0x1709 0x1700
|
||||
KEY_J 0x0024 J 0x246A 0x244A 0x240A 0x2400
|
||||
KEY_K 0x0025 K 0x256B 0x254B 0x250B 0x2500
|
||||
KEY_L 0x0026 L 0x266C 0x264C 0x260C 0x2600
|
||||
KEY_M 0x0032 M 0x326D 0x324D 0x320D 0x3200
|
||||
KEY_N 0x0031 N 0x316E 0x314E 0x310E 0x3100
|
||||
KEY_O 0x0018 O 0x186F 0x184F 0x180F 0x1800
|
||||
KEY_P 0x0019 P 0x1970 0x1950 0x1910 0x1900
|
||||
KEY_Q 0x0010 Q 0x1071 0x1051 0x1011 0x1000
|
||||
KEY_R 0x0013 R 0x1372 0x1352 0x1312 0x1300
|
||||
KEY_S 0x001F S 0x1F73 0x1F53 0x1F13 0x1F00
|
||||
KEY_T 0x0014 T 0x1474 0x1454 0x1414 0x1400
|
||||
KEY_U 0x0016 U 0x1675 0x1655 0x1615 0x1600
|
||||
KEY_V 0x002F V 0x2F76 0x2F56 0x2F16 0x2F00
|
||||
KEY_W 0x0011 W 0x1177 0x1157 0x1117 0x1100
|
||||
KEY_X 0x002D X 0x2D78 0x2D58 0x2D18 0x2D00
|
||||
KEY_Y 0x0015 Y 0x1579 0x1559 0x1519 0x1500
|
||||
KEY_Z 0x002C Z 0x2C7A 0x2C5A 0x2C1A 0x2C00
|
||||
|
||||
KEY_1 0x0002 1 ! 0x0231 0x0221 0x0000 0x7800
|
||||
KEY_2 0x0003 2 " 0x0332 0x0322 0x0300 0x7900
|
||||
KEY_3 0x0004 3 £ 0x0433 0x049C 0x0000 0x7A00
|
||||
KEY_4 0x0005 4 $ 0x0534 0x0524 0x0000 0x7B00
|
||||
KEY_5 0x0006 5 % 0x0635 0x0625 0x0000 0x7C00
|
||||
KEY_6 0x0007 6 & 0x0736 0x075E 0x071E 0x7D00
|
||||
KEY_7 0x0008 7 / 0x0837 0x0826 0x0000 0x7E00
|
||||
KEY_8 0x0009 8 ( 0x0938 0x0928 0x0000 0x7F00
|
||||
KEY_9 0x000A 9 ) 0x0A39 0x0A29 0x0000 0x8000
|
||||
KEY_0 0x000B 0 = 0x0B30 0x0B3D 0x0000 0x8100
|
||||
|
||||
KEY_GRAVE 0x0029 \ | 0x295C 0x297C 0x0000 0x2900
|
||||
KEY_APOSTROPHE 0x000C ' ? 0x0C27 0x0C3F 0x0000 0x8200
|
||||
KEY_I_ACC 0x000D ì ^ 0x0D8D 0x0D5E 0x0000 0x8300
|
||||
KEY_LEFT_BRAKET 0x001A è é [ 0x1A8A 0x1A82 0x0000 0x1A5B
|
||||
KEY_RIGHT_BRAKET 0x001B + * ] 0x1B2B 0x1B2A 0x0000 0x1B5D
|
||||
KEY_SEMICOLON 0x0027 ò ç @ 0x2795 0x2780 0x0000 0x2740
|
||||
KEY_DOUBLE_QUOTES 0x0028 à ° # 0x2885 0x28A7 0x0000 0x2823
|
||||
KEY_BACKSLASH 0x002B ù § 0x2B97 0x2BA7 0x0000 0x2B00
|
||||
KEY_KP_LESS 0x0056 < > 0x563C 0x563E 0x0000 0x5600
|
||||
KEY_COMMA 0x0033 , ; 0x332C 0x333B 0x0000 0x3300
|
||||
KEY_PERIOD 0x0034 . : 0x342E 0x343A 0x0000 0x3400
|
||||
KEY_MINUS 0x0035 - _ 0x352D 0x355F 0x0000 0x3500
|
||||
|
||||
KEY_F1 0x003B F1 0x3B00 0x5400 0x5E00 0x6800
|
||||
KEY_F2 0x003C F2 0x3C00 0x5500 0x5F00 0x6900
|
||||
KEY_F3 0x003D F3 0x3D00 0x5600 0x6000 0x6A00
|
||||
KEY_F4 0x003E F4 0x3E00 0x5700 0x6100 0x6B00
|
||||
KEY_F5 0x003F F5 0x3F00 0x5800 0x6200 0x6C00
|
||||
KEY_F6 0x0040 F6 0x4000 0x5900 0x6300 0x6D00
|
||||
KEY_F7 0x0041 F7 0x4100 0x5A00 0x6400 0x6E00
|
||||
KEY_F8 0x0042 F8 0x4200 0x5B00 0x6500 0x6F00
|
||||
KEY_F9 0x0043 F9 0x4300 0x5C00 0x6600 0x7000
|
||||
KEY_F10 0x0044 F10 0x4400 0x5D00 0x6700 0x7100
|
||||
KEY_F11 0x0057 F11 0x5700 0x5900 0x5B00 0x5D00
|
||||
KEY_F12 0x0058 F12 0x5800 0x5A00 0x5C00 0x5E00
|
||||
|
||||
KEY_BACKSPACE 0x000E BackSpace 0x0E08 0x0E08 0x0E7F 0x0E00
|
||||
KEY_ENTER 0x001C Enter 0x1C0D 0x1C0D 0x1C0A 0xA600
|
||||
KEY_ESCAPE 0x0001 Esc 0x011B 0x011B 0x011B 0x0100
|
||||
KEY_TAB 0x000F Tab 0x0F09 0x0F00 0x9400 0xA500
|
||||
KEY_SPACE 0x0039 SpaceBar 0x3920 0x3920 0x3920 0x3920
|
||||
|
||||
KEY_INSERT 0xE052 Ins 0x5200 0x5230 0x9200 0xA200
|
||||
KEY_HOME 0xE047 Home 0x4700 0x4737 0x7700 0x9700
|
||||
KEY_PAGE_UP 0xE049 PgUp 0x4900 0x4939 0x8400 0x9900
|
||||
KEY_DELETE 0xE053 Del 0x5300 0x532E 0x9300 0xA300
|
||||
KEY_END 0xE04F End 0x4F00 0x4F31 0x7500 0x9F00
|
||||
KEY_PAGE_DOWN 0xE051 PgDn 0x5100 0x5133 0x7600 0xA100
|
||||
|
||||
KEY_UP_ARROW 0xE048 Up Arrow 0x4800 0x4838 0x8D00 0x9800
|
||||
KEY_DOWN_ARROW 0xE050 Down Arrow 0x5000 0x5032 0x9100 0xA000
|
||||
KEY_LEFT_ARROW 0xE04B Left Arrow 0x4B00 0x4B34 0x7300 0x9B00
|
||||
KEY_RIGHT_ARROW 0xE04D Right Arrow 0x4D00 0x4D36 0x7400 0x9D00
|
||||
|
||||
KEY_KP_DIV 0xE035 Kp.Div 0xE035 0xE035 0x3500 0x3500
|
||||
KEY_KP_MUL 0x0037 Kp.Mul 0x372A 0x372A 0x3700 0x3700
|
||||
KEY_KP_SUB 0x004A Kp.Sub 0x4A2D 0x4A2D 0x4A00 0x4A00
|
||||
KEY_KP_ADD 0x004E Kp.Add 0x4E2B 0x4E2B 0x4E00 0x4E00
|
||||
KEY_KP_RETURN 0xE01C Kp.Enter 0xE01C 0xE01C 0x1C00 0x1C00
|
||||
|
||||
KEY_KP7 0x0047 0x4737 0x4737 0x4700 0x4700
|
||||
KEY_KP8 0x0048 0x4838 0x4838 0x4800 0x4800
|
||||
KEY_KP9 0x0049 0x4939 0x4939 0x4900 0x4900
|
||||
KEY_KP4 0x004B 0x4B34 0x4B34 0x4B00 0x4B00
|
||||
KEY_KP5 0x004C 0x4C35 0x4C35 0x4C00 0x4C00
|
||||
KEY_KP6 0x004D 0x4D36 0x4D36 0x4D00 0x4D00
|
||||
KEY_KP1 0x004F 0x4F31 0x4F31 0x4F00 0x4F00
|
||||
KEY_KP2 0x0050 0x5032 0x5032 0x5000 0x5000
|
||||
KEY_KP3 0x0051 0x5133 0x5133 0x5100 0x5100
|
||||
KEY_KP0 0x0052 0x5230 0x5230 0x5200 0x5200
|
||||
|
||||
KEY_KP_DEC 0x0053 0x532E 0x532E 0x5300 0x5300
|
||||
@@ -0,0 +1,49 @@
|
||||
# Signal
|
||||
|
||||
## Legenda
|
||||
|
||||
The **first column** of the table represent the implementation status,
|
||||
specifically:
|
||||
|
||||
1. Implemented
|
||||
2. Tested
|
||||
|
||||
If the column is empty it means that it's not implemented yet.
|
||||
|
||||
## Implementation Status
|
||||
|
||||
```
|
||||
S | Number | Signal | Standard | Action | Comment
|
||||
---+--------+-----------+----------+--------+------------------------------
|
||||
| 1 | SIGHUP | P1990 | Term | Hangup detected on controlling terminal or death of controlling process
|
||||
| 2 | SIGINT | P1990 | Term | Interrupt from keyboard
|
||||
| 3 | SIGQUIT | P1990 | Core | Quit from keyboard
|
||||
| 4 | SIGILL | P1990 | Core | Illegal Instruction
|
||||
| 5 | SIGTRAP | P2001 | Core | Trace/breakpoint trap
|
||||
2 | 6 | SIGABRT | P1990 | Core | Abort signal from abort(3)
|
||||
| 7 | SIGEMT | - | Term | Emulator trap
|
||||
2 | 8 | SIGFPE | P1990 | Core | Floating-point exception
|
||||
2 | 9 | SIGKILL | P1990 | Term | Kill signal
|
||||
| 10 | SIGBUS | P2001 | Core | Bus error (bad memory access)
|
||||
| 11 | SIGSEGV | P1990 | Core | Invalid memory reference
|
||||
| 12 | SIGSYS | P2001 | Core | Bad system call (SVr4); see also seccomp(2)
|
||||
| 13 | SIGPIPE | P1990 | Term | Broken pipe: write to pipe with no readers; see pipe(7)
|
||||
2 | 14 | SIGALRM | P1990 | Term | Timer signal from alarm(2)
|
||||
2 | 15 | SIGTERM | P1990 | Term | Termination signal
|
||||
2 | 16 | SIGUSR1 | P1990 | Term | User-defined signal 1
|
||||
2 | 17 | SIGUSR2 | P1990 | Term | User-defined signal 2
|
||||
1 | 18 | SIGCHLD | P1990 | Ign | Child stopped or terminated
|
||||
| 19 | SIGPWR | - | Term | Power failure (System V)
|
||||
| 20 | SIGWINCH | - | Ign | Window resize signal (4.3BSD, Sun)
|
||||
| 21 | SIGURG | P2001 | Ign | Urgent condition on socket (4.2BSD)
|
||||
| 22 | SIGPOLL | P2001 | Term | Pollable event (Sys V); synonym for SIGIO
|
||||
2 | 23 | SIGSTOP | P1990 | Stop | Stop process
|
||||
| 24 | SIGTSTP | P1990 | Stop | Stop typed at terminal
|
||||
2 | 25 | SIGCONT | P1990 | Cont | Continue if stopped
|
||||
| 26 | SIGTTIN | P1990 | Stop | Terminal input for background process
|
||||
| 27 | SIGTTOU | P1990 | Stop | Terminal output for background process
|
||||
| 28 | SIGVTALRM | P2001 | Term | Virtual alarm clock (4.2BSD)
|
||||
2 | 29 | SIGPROF | P2001 | Term | Profiling timer expired
|
||||
| 30 | SIGXCPU | P2001 | Core | CPU time limit exceeded (4.2BSD); see setrlimit(2)
|
||||
| 31 | SIGXFSZ | P2001 | Core | File size limit exceeded (4.2BSD); see setrlimit(2)
|
||||
```
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
# System Call
|
||||
|
||||
## Legenda
|
||||
|
||||
The **first column** of the table represent the implementation status,
|
||||
specifically:
|
||||
|
||||
1. Implemented
|
||||
2. Tested
|
||||
X. Obsolete
|
||||
|
||||
If the column is empty it means that it's not implemented yet.
|
||||
|
||||
## Implementation Status
|
||||
|
||||
```
|
||||
S | EAX | Name | Source | EBX | ECX | EDX | ESX | EDI |
|
||||
---+-----+----------------------------+-----------------------------+--------------------------+------------------------------+-------------------------+-----------------+------------------|
|
||||
2 | 1 | sys_exit | kernel/exit.c | int | - | - | - | - |
|
||||
2 | 2 | sys_fork | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
2 | 3 | sys_read | fs/read_write.c | unsigned int | char * | size_t | - | - |
|
||||
2 | 4 | sys_write | fs/read_write.c | unsigned int | const char * | size_t | - | - |
|
||||
2 | 5 | sys_open | fs/open.c | const char * | int | int | - | - |
|
||||
2 | 6 | sys_close | fs/open.c | int | - | - | - | - |
|
||||
2 | 7 | sys_waitpid | kernel/exit.c | pid_t | unsigned int * | int | - | - |
|
||||
2 | 8 | sys_creat | fs/open.c | const char * | int | - | - | - |
|
||||
| 9 | sys_link | fs/namei.c | const char * | const char * | - | - | - |
|
||||
2 | 10 | sys_unlink | fs/namei.c | const char * | - | - | - | - |
|
||||
2 | 11 | sys_execve | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
2 | 12 | sys_chdir | fs/open.c | const char * | - | - | - | - |
|
||||
2 | 13 | sys_time | kernel/time.c | int * | - | - | - | - |
|
||||
| 14 | sys_mknod | fs/namei.c | const char * | int | dev_t | - | - |
|
||||
| 15 | sys_chmod | fs/open.c | const char * | mode_t | - | - | - |
|
||||
| 16 | sys_lchown | fs/open.c | const char * | uid_t | gid_t | - | - |
|
||||
2 | 18 | sys_stat | fs/stat.c | char * | struct __old_kernel_stat * | - | - | - |
|
||||
2 | 19 | sys_lseek | fs/read_write.c | unsigned int | off_t | unsigned int | - | - |
|
||||
2 | 20 | sys_getpid | kernel/sched.c | - | - | - | - | - |
|
||||
| 21 | sys_mount | fs/super.c | char * | char * | char * | - | - |
|
||||
| 22 | sys_oldumount | fs/super.c | char * | - | - | - | - |
|
||||
2 | 23 | sys_setuid | kernel/sys.c | uid_t | - | - | - | - |
|
||||
2 | 24 | sys_getuid | kernel/sched.c | - | - | - | - | - |
|
||||
| 25 | sys_stime | kernel/time.c | int * | - | - | - | - |
|
||||
| 26 | sys_ptrace | arch/i386/kernel/ptrace.c | long | long | long | long | - |
|
||||
2 | 27 | sys_alarm | kernel/sched.c | unsigned int | - | - | - | - |
|
||||
2 | 28 | sys_fstat | fs/stat.c | unsigned int | struct __old_kernel_stat * | - | - | - |
|
||||
| 29 | sys_pause | arch/i386/kernel/sys_i386.c | - | - | - | - | - |
|
||||
| 30 | sys_utime | fs/open.c | char * | struct utimbuf * | - | - | - |
|
||||
| 33 | sys_access | fs/open.c | const char * | int | - | - | - |
|
||||
1 | 34 | sys_nice | kernel/sched.c | int | - | - | - | - |
|
||||
| 36 | sys_sync | fs/buffer.c | - | - | - | - | - |
|
||||
1 | 37 | sys_kill | kernel/signal.c | int | int | - | - | - |
|
||||
| 38 | sys_rename | fs/namei.c | const char * | const char * | - | - | - |
|
||||
2 | 39 | sys_mkdir | fs/namei.c | const char * | int | - | - | - |
|
||||
2 | 40 | sys_rmdir | fs/namei.c | const char * | - | - | - | - |
|
||||
| 41 | sys_dup | fs/fcntl.c | unsigned int | - | - | - | - |
|
||||
| 42 | sys_pipe | arch/i386/kernel/sys_i386.c | unsigned long * | - | - | - | - |
|
||||
| 43 | sys_times | kernel/sys.c | struct tms * | - | - | - | - |
|
||||
2 | 45 | sys_brk | mm/mmap.c | unsigned long | - | - | - | - |
|
||||
2 | 46 | sys_setgid | kernel/sys.c | gid_t | - | - | - | - |
|
||||
2 | 47 | sys_getgid | kernel/sched.c | - | - | - | - | - |
|
||||
1 | 48 | sys_signal | kernel/signal.c | int | __sighandler_t | - | - | - |
|
||||
| 49 | sys_geteuid | kernel/sched.c | - | - | - | - | - |
|
||||
| 50 | sys_getegid | kernel/sched.c | - | - | - | - | - |
|
||||
| 51 | sys_acct | kernel/acct.c | const char * | - | - | - | - |
|
||||
| 52 | sys_umount | fs/super.c | char * | int | - | - | - |
|
||||
1 | 54 | sys_ioctl | fs/ioctl.c | unsigned int | unsigned int | unsigned long | - | - |
|
||||
| 55 | sys_fcntl | fs/fcntl.c | unsigned int | unsigned int | unsigned long | - | - |
|
||||
2 | 57 | sys_setpgid | kernel/sys.c | pid_t | pid_t | - | - | - |
|
||||
| 59 | sys_olduname | arch/i386/kernel/sys_i386.c | struct oldold_utsname * | - | - | - | - |
|
||||
| 60 | sys_umask | kernel/sys.c | int | - | - | - | - |
|
||||
| 61 | sys_chroot | fs/open.c | const char * | - | - | - | - |
|
||||
| 62 | sys_ustat | fs/super.c | dev_t | struct ustat * | - | - | - |
|
||||
| 63 | sys_dup2 | fs/fcntl.c | unsigned int | unsigned int | - | - | - |
|
||||
2 | 64 | sys_getppid | kernel/sched.c | - | - | - | - | - |
|
||||
| 65 | sys_getpgrp | kernel/sys.c | - | - | - | - | - |
|
||||
2 | 66 | sys_setsid | kernel/sys.c | - | - | - | - | - |
|
||||
1 | 67 | sys_sigaction | arch/i386/kernel/signal.c | int | const struct old_sigaction * | struct old_sigaction * | - | - |
|
||||
X | 68 | sys_sgetmask | kernel/signal.c | - | - | - | - | - |
|
||||
X | 69 | sys_ssetmask | kernel/signal.c | int | - | - | - | - |
|
||||
| 70 | sys_setreuid | kernel/sys.c | uid_t | uid_t | - | - | - |
|
||||
| 71 | sys_setregid | kernel/sys.c | gid_t | gid_t | - | - | - |
|
||||
| 72 | sys_sigsuspend | arch/i386/kernel/signal.c | int | int | old_sigset_t | - | - |
|
||||
| 73 | sys_sigpending | kernel/signal.c | old_sigset_t * | - | - | - | - |
|
||||
| 74 | sys_sethostname | kernel/sys.c | char * | int | - | - | - |
|
||||
| 75 | sys_setrlimit | kernel/sys.c | unsigned int | struct rlimit * | - | - | - |
|
||||
| 76 | sys_getrlimit | kernel/sys.c | unsigned int | struct rlimit * | - | - | - |
|
||||
| 77 | sys_getrusage | kernel/sys.c | int | struct rusage * | - | - | - |
|
||||
| 78 | sys_gettimeofday | kernel/time.c | struct timeval * | struct timezone * | - | - | - |
|
||||
| 79 | sys_settimeofday | kernel/time.c | struct timeval * | struct timezone * | - | - | - |
|
||||
| 80 | sys_getgroups | kernel/sys.c | int | gid_t * | - | - | - |
|
||||
| 81 | sys_setgroups | kernel/sys.c | int | gid_t * | - | - | - |
|
||||
| 83 | sys_symlink | fs/namei.c | const char * | const char * | - | - | - |
|
||||
| 84 | sys_lstat | fs/stat.c | char * | struct __old_kernel_stat * | - | - | - |
|
||||
| 85 | sys_readlink | fs/stat.c | const char * | char * | int | - | - |
|
||||
| 86 | sys_uselib | fs/exec.c | const char * | - | - | - | - |
|
||||
| 87 | sys_swapon | mm/swapfile.c | const char * | int | - | - | - |
|
||||
1 | 88 | sys_reboot | kernel/sys.c | int | int | int | void * | - |
|
||||
1 | 89 | old_readdir | fs/readdir.c | unsigned int | void * | unsigned int | - | - |
|
||||
| 90 | old_mmap | arch/i386/kernel/sys_i386.c | struct mmap_arg_struct * | - | - | - | - |
|
||||
| 91 | sys_munmap | mm/mmap.c | unsigned long | size_t | - | - | - |
|
||||
| 92 | sys_truncate | fs/open.c | const char * | unsigned long | - | - | - |
|
||||
| 93 | sys_ftruncate | fs/open.c | unsigned int | unsigned long | - | - | - |
|
||||
| 94 | sys_fchmod | fs/open.c | unsigned int | mode_t | - | - | - |
|
||||
| 95 | sys_fchown | fs/open.c | unsigned int | uid_t | gid_t | - | - |
|
||||
| 96 | sys_getpriority | kernel/sys.c | int | int | - | - | - |
|
||||
| 97 | sys_setpriority | kernel/sys.c | int | int | int | - | - |
|
||||
| 99 | sys_statfs | fs/open.c | const char * | struct statfs * | - | - | - |
|
||||
| 100 | sys_fstatfs | fs/open.c | unsigned int | struct statfs * | - | - | - |
|
||||
| 101 | sys_ioperm | arch/i386/kernel/ioport.c | unsigned long | unsigned long | int | - | - |
|
||||
| 102 | sys_socketcall | net/socket.c | int | unsigned long * | - | - | - |
|
||||
| 103 | sys_syslog | kernel/printk.c | int | char * | int | - | - |
|
||||
| 104 | sys_setitimer | kernel/itimer.c | int | struct itimerval * | struct itimerval * | - | - |
|
||||
| 105 | sys_getitimer | kernel/itimer.c | int | struct itimerval * | - | - | - |
|
||||
| 106 | sys_newstat | fs/stat.c | char * | struct stat * | - | - | - |
|
||||
| 107 | sys_newlstat | fs/stat.c | char * | struct stat * | - | - | - |
|
||||
| 108 | sys_newfstat | fs/stat.c | unsigned int | struct stat * | - | - | - |
|
||||
1 | 109 | sys_uname | arch/i386/kernel/sys_i386.c | struct old_utsname * | - | - | - | - |
|
||||
| 110 | sys_iopl | arch/i386/kernel/ioport.c | unsigned long | - | - | - | - |
|
||||
| 111 | sys_vhangup | fs/open.c | - | - | - | - | - |
|
||||
| 112 | sys_idle | arch/i386/kernel/process.c | - | - | - | - | - |
|
||||
| 113 | sys_vm86old | arch/i386/kernel/vm86.c | unsigned long | struct vm86plus_struct * | - | - | - |
|
||||
| 114 | sys_wait4 | kernel/exit.c | pid_t | unsigned long * | int options | struct rusage * | - |
|
||||
| 115 | sys_swapoff | mm/swapfile.c | const char * | - | - | - | - |
|
||||
| 116 | sys_sysinfo | kernel/info.c | struct sysinfo * | - | - | - | - |
|
||||
* | 117 | sys_ipc(*Note) | arch/i386/kernel/sys_i386.c | uint | int | int | int | void * |
|
||||
| 118 | sys_fsync | fs/buffer.c | unsigned int | - | - | - | - |
|
||||
| 119 | sys_sigreturn | arch/i386/kernel/signal.c | unsigned long | - | - | - | - |
|
||||
| 120 | sys_clone | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
| 121 | sys_setdomainname | kernel/sys.c | char * | int | - | - | - |
|
||||
| 122 | sys_newuname | kernel/sys.c | struct new_utsname * | - | - | - | - |
|
||||
| 123 | sys_modify_ldt | arch/i386/kernel/ldt.c | int | void * | unsigned long | - | - |
|
||||
| 124 | sys_adjtimex | kernel/time.c | struct timex * | - | - | - | - |
|
||||
| 125 | sys_mprotect | mm/mprotect.c | unsigned long | size_t | unsigned long | - | - |
|
||||
1 | 126 | sys_sigprocmask | kernel/signal.c | int | old_sigset_t * | old_sigset_t * | - | - |
|
||||
| 127 | sys_create_module | kernel/module.c | const char * | size_t | - | - | - |
|
||||
| 128 | sys_init_module | kernel/module.c | const char * | struct module * | - | - | - |
|
||||
| 129 | sys_delete_module | kernel/module.c | const char * | - | - | - | - |
|
||||
| 130 | sys_get_kernel_syms | kernel/module.c | struct kernel_sym * | - | - | - | - |
|
||||
| 131 | sys_quotactl | fs/dquot.c | int | const char * | int | caddr_t | - |
|
||||
| 132 | sys_getpgid | kernel/sys.c | pid_t | - | - | - | - |
|
||||
1 | 133 | sys_fchdir | fs/open.c | unsigned int | - | - | - | - |
|
||||
| 134 | sys_bdflush | fs/buffer.c | int | long | - | - | - |
|
||||
| 135 | sys_sysfs | fs/super.c | int | unsigned long | unsigned long | - | - |
|
||||
| 136 | sys_personality | kernel/exec_domain.c | unsigned long | - | - | - | - |
|
||||
| 138 | sys_setfsuid | kernel/sys.c | uid_t | - | - | - | - |
|
||||
| 139 | sys_setfsgid | kernel/sys.c | gid_t | - | - | - | - |
|
||||
| 140 | sys_llseek | fs/read_write.c | unsigned int | unsigned long | unsigned long | loff_t * | unsigned int |
|
||||
2 | 141 | sys_getdents | fs/readdir.c | unsigned int | void * | unsigned int | - | - |
|
||||
| 142 | sys_select | fs/select.c | int | fd_set * | fd_set * | fd_set * | struct timeval * |
|
||||
| 143 | sys_flock | fs/locks.c | unsigned int | unsigned int | - | - | - |
|
||||
| 144 | sys_msync | mm/filemap.c | unsigned long | size_t | int | - | - |
|
||||
| 145 | sys_readv | fs/read_write.c | unsigned long | const struct iovec * | unsigned long | - | - |
|
||||
| 146 | sys_writev | fs/read_write.c | unsigned long | const struct iovec * | unsigned long | - | - |
|
||||
| 147 | sys_getsid | kernel/sys.c | pid_t | - | - | - | - |
|
||||
| 148 | sys_fdatasync | fs/buffer.c | unsigned int | - | - | - | - |
|
||||
| 149 | sys_sysctl | kernel/sysctl.c | struct __sysctl_args * | - | - | - | - |
|
||||
| 150 | sys_mlock | mm/mlock.c | unsigned long | size_t | - | - | - |
|
||||
| 151 | sys_munlock | mm/mlock.c | unsigned long | size_t | - | - | - |
|
||||
| 152 | sys_mlockall | mm/mlock.c | int | - | - | - | - |
|
||||
| 153 | sys_munlockall | mm/mlock.c | - | - | - | - | - |
|
||||
1 | 154 | sys_sched_setparam | kernel/sched.c | pid_t | struct sched_param * | - | - | - |
|
||||
1 | 155 | sys_sched_getparam | kernel/sched.c | pid_t | struct sched_param * | - | - | - |
|
||||
| 156 | sys_sched_setscheduler | kernel/sched.c | pid_t | int | struct sched_param * | - | - |
|
||||
| 157 | sys_sched_getscheduler | kernel/sched.c | pid_t | - | - | - | - |
|
||||
| 158 | sys_sched_yield | kernel/sched.c | - | - | - | - | - |
|
||||
| 159 | sys_sched_get_priority_max | kernel/sched.c | int | - | - | - | - |
|
||||
| 160 | sys_sched_get_priority_min | kernel/sched.c | int | - | - | - | - |
|
||||
| 161 | sys_sched_rr_get_interval | kernel/sched.c | pid_t | struct timespec * | - | - | - |
|
||||
| 162 | sys_nanosleep | kernel/sched.c | struct timespec * | struct timespec * | - | - | - |
|
||||
| 163 | sys_mremap | mm/mremap.c | unsigned long | unsigned long | unsigned long | unsigned long | - |
|
||||
| 164 | sys_setresuid | kernel/sys.c | uid_t | uid_t | uid_t | - | - |
|
||||
| 165 | sys_getresuid | kernel/sys.c | uid_t * | uid_t * | uid_t * | - | - |
|
||||
| 166 | sys_vm86 | arch/i386/kernel/vm86.c | struct vm86_struct * | - | - | - | - |
|
||||
| 167 | sys_query_module | kernel/module.c | const char * | int | char * | size_t | size_t * |
|
||||
| 168 | sys_poll | fs/select.c | struct pollfd * | unsigned int | long | - | - |
|
||||
| 169 | sys_nfsservctl | fs/filesystems.c | int | void * | void * | - | - |
|
||||
| 170 | sys_setresgid | kernel/sys.c | gid_t | gid_t | gid_t | - | - |
|
||||
| 171 | sys_getresgid | kernel/sys.c | gid_t * | gid_t * | gid_t * | - | - |
|
||||
| 172 | sys_prctl | kernel/sys.c | int | unsigned long | unsigned long | unsigned long | unsigned long |
|
||||
| 173 | sys_rt_sigreturn | arch/i386/kernel/signal.c | unsigned long | - | - | - | - |
|
||||
| 174 | sys_rt_sigaction | kernel/signal.c | int | const struct sigaction * | struct sigaction * | size_t | - |
|
||||
| 175 | sys_rt_sigprocmask | kernel/signal.c | int | sigset_t * | sigset_t * | size_t | - |
|
||||
| 176 | sys_rt_sigpending | kernel/signal.c | sigset_t * | size_t | - | - | - |
|
||||
| 177 | sys_rt_sigtimedwait | kernel/signal.c | const sigset_t * | siginfo_t * | const struct timespec * | size_t | - |
|
||||
| 178 | sys_rt_sigqueueinfo | kernel/signal.c | int | int | siginfo_t * | - | - |
|
||||
| 179 | sys_rt_sigsuspend | arch/i386/kernel/signal.c | sigset_t * | size_t | - | - | - |
|
||||
| 180 | sys_pread | fs/read_write.c | unsigned int | char * | size_t | loff_t | - |
|
||||
| 181 | sys_pwrite | fs/read_write.c | unsigned int | const char * | size_t | loff_t | - |
|
||||
| 182 | sys_chown | fs/open.c | const char * | uid_t | gid_t | - | - |
|
||||
1 | 183 | sys_getcwd | fs/dcache.c | char * | unsigned long | - | - | - |
|
||||
| 184 | sys_capget | kernel/capability.c | cap_user_header_t | cap_user_data_t | - | - | - |
|
||||
| 185 | sys_capset | kernel/capability.c | cap_user_header_t | const cap_user_data_t | - | - | - |
|
||||
| 186 | sys_sigaltstack | arch/i386/kernel/signal.c | const stack_t * | stack_t * | - | - | - |
|
||||
| 187 | sys_sendfile | mm/filemap.c | int | int | off_t * | size_t | - |
|
||||
| | | | | | | | |
|
||||
2 | 188 | sys_waitperiod | kernel/sched.c | | | | | |
|
||||
| 189 | sys_msgctl | | int | | | | |
|
||||
| 190 | sys_msgget | | | | | | |
|
||||
| 191 | sys_msgrcv | | | | | | |
|
||||
| 192 | sys_msgsnd | | | | | | |
|
||||
| 193 | sys_semctl | | | | | | |
|
||||
| 194 | sys_semget | | | | | | |
|
||||
| 195 | sys_semop | | | | | | |
|
||||
| 196 | sys_shmat | | | | | | |
|
||||
| 197 | sys_shmctl | | | | | | |
|
||||
| 198 | sys_shmdt | | | | | | |
|
||||
| 199 | sys_shmget | | | | | | |
|
||||
```
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
| EAX | Name | Source | EBX | ECX | EDX | ESX | EDI |
|
||||
|:----|:---------------------------|:----------------------------|:-------------------------|:-----------------------------|:------------------------|:----------------|:-----------------|
|
||||
| 1 | sys_exit | kernel/exit.c | int | - | - | - | - |
|
||||
| 2 | sys_fork | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
| 3 | sys_read | fs/read_write.c | unsigned int | char * | size_t | - | - |
|
||||
| 4 | sys_write | fs/read_write.c | unsigned int | const char * | size_t | - | - |
|
||||
| 5 | sys_open | fs/open.c | const char * | int | int | - | - |
|
||||
| 6 | sys_close | fs/open.c | unsigned int | - | - | - | - |
|
||||
| 7 | sys_waitpid | kernel/exit.c | pid_t | unsigned int * | int | - | - |
|
||||
| 8 | sys_creat | fs/open.c | const char * | int | - | - | - |
|
||||
| 9 | sys_link | fs/namei.c | const char * | const char * | - | - | - |
|
||||
| 10 | sys_unlink | fs/namei.c | const char * | - | - | - | - |
|
||||
| 11 | sys_execve | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
| 12 | sys_chdir | fs/open.c | const char * | - | - | - | - |
|
||||
| 13 | sys_time | kernel/time.c | int * | - | - | - | - |
|
||||
| 14 | sys_mknod | fs/namei.c | const char * | int | dev_t | - | - |
|
||||
| 15 | sys_chmod | fs/open.c | const char * | mode_t | - | - | - |
|
||||
| 16 | sys_lchown | fs/open.c | const char * | uid_t | gid_t | - | - |
|
||||
| 18 | sys_stat | fs/stat.c | char * | struct __old_kernel_stat * | - | - | - |
|
||||
| 19 | sys_lseek | fs/read_write.c | unsigned int | off_t | unsigned int | - | - |
|
||||
| 20 | sys_getpid | kernel/sched.c | - | - | - | - | - |
|
||||
| 21 | sys_mount | fs/super.c | char * | char * | char * | - | - |
|
||||
| 22 | sys_oldumount | fs/super.c | char * | - | - | - | - |
|
||||
| 23 | sys_setuid | kernel/sys.c | uid_t | - | - | - | - |
|
||||
| 24 | sys_getuid | kernel/sched.c | - | - | - | - | - |
|
||||
| 25 | sys_stime | kernel/time.c | int * | - | - | - | - |
|
||||
| 26 | sys_ptrace | arch/i386/kernel/ptrace.c | long | long | long | long | - |
|
||||
| 27 | sys_alarm | kernel/sched.c | unsigned int | - | - | - | - |
|
||||
| 28 | sys_fstat | fs/stat.c | unsigned int | struct __old_kernel_stat * | - | - | - |
|
||||
| 29 | sys_pause | arch/i386/kernel/sys_i386.c | - | - | - | - | - |
|
||||
| 30 | sys_utime | fs/open.c | char * | struct utimbuf * | - | - | - |
|
||||
| 33 | sys_access | fs/open.c | const char * | int | - | - | - |
|
||||
| 34 | sys_nice | kernel/sched.c | int | - | - | - | - |
|
||||
| 36 | sys_sync | fs/buffer.c | - | - | - | - | - |
|
||||
| 37 | sys_kill | kernel/signal.c | int | int | - | - | - |
|
||||
| 38 | sys_rename | fs/namei.c | const char * | const char * | - | - | - |
|
||||
| 39 | sys_mkdir | fs/namei.c | const char * | int | - | - | - |
|
||||
| 40 | sys_rmdir | fs/namei.c | const char * | - | - | - | - |
|
||||
| 41 | sys_dup | fs/fcntl.c | unsigned int | - | - | - | - |
|
||||
| 42 | sys_pipe | arch/i386/kernel/sys_i386.c | unsigned long * | - | - | - | - |
|
||||
| 43 | sys_times | kernel/sys.c | struct tms * | - | - | - | - |
|
||||
| 45 | sys_brk | mm/mmap.c | unsigned long | - | - | - | - |
|
||||
| 46 | sys_setgid | kernel/sys.c | gid_t | - | - | - | - |
|
||||
| 47 | sys_getgid | kernel/sched.c | - | - | - | - | - |
|
||||
| 48 | sys_signal | kernel/signal.c | int | __sighandler_t | - | - | - |
|
||||
| 49 | sys_geteuid | kernel/sched.c | - | - | - | - | - |
|
||||
| 50 | sys_getegid | kernel/sched.c | - | - | - | - | - |
|
||||
| 51 | sys_acct | kernel/acct.c | const char * | - | - | - | - |
|
||||
| 52 | sys_umount | fs/super.c | char * | int | - | - | - |
|
||||
| 54 | sys_ioctl | fs/ioctl.c | unsigned int | unsigned int | unsigned long | - | - |
|
||||
| 55 | sys_fcntl | fs/fcntl.c | unsigned int | unsigned int | unsigned long | - | - |
|
||||
| 57 | sys_setpgid | kernel/sys.c | pid_t | pid_t | - | - | - |
|
||||
| 59 | sys_olduname | arch/i386/kernel/sys_i386.c | struct oldold_utsname * | - | - | - | - |
|
||||
| 60 | sys_umask | kernel/sys.c | int | - | - | - | - |
|
||||
| 61 | sys_chroot | fs/open.c | const char * | - | - | - | - |
|
||||
| 62 | sys_ustat | fs/super.c | dev_t | struct ustat * | - | - | - |
|
||||
| 63 | sys_dup2 | fs/fcntl.c | unsigned int | unsigned int | - | - | - |
|
||||
| 64 | sys_getppid | kernel/sched.c | - | - | - | - | - |
|
||||
| 65 | sys_getpgrp | kernel/sys.c | - | - | - | - | - |
|
||||
| 66 | sys_setsid | kernel/sys.c | - | - | - | - | - |
|
||||
| 67 | sys_sigaction | arch/i386/kernel/signal.c | int | const struct old_sigaction * | struct old_sigaction * | - | - |
|
||||
| 68 | sys_sgetmask | kernel/signal.c | - | - | - | - | - |
|
||||
| 69 | sys_ssetmask | kernel/signal.c | int | - | - | - | - |
|
||||
| 70 | sys_setreuid | kernel/sys.c | uid_t | uid_t | - | - | - |
|
||||
| 71 | sys_setregid | kernel/sys.c | gid_t | gid_t | - | - | - |
|
||||
| 72 | sys_sigsuspend | arch/i386/kernel/signal.c | int | int | old_sigset_t | - | - |
|
||||
| 73 | sys_sigpending | kernel/signal.c | old_sigset_t * | - | - | - | - |
|
||||
| 74 | sys_sethostname | kernel/sys.c | char * | int | - | - | - |
|
||||
| 75 | sys_setrlimit | kernel/sys.c | unsigned int | struct rlimit * | - | - | - |
|
||||
| 76 | sys_getrlimit | kernel/sys.c | unsigned int | struct rlimit * | - | - | - |
|
||||
| 77 | sys_getrusage | kernel/sys.c | int | struct rusage * | - | - | - |
|
||||
| 78 | sys_gettimeofday | kernel/time.c | struct timeval * | struct timezone * | - | - | - |
|
||||
| 79 | sys_settimeofday | kernel/time.c | struct timeval * | struct timezone * | - | - | - |
|
||||
| 80 | sys_getgroups | kernel/sys.c | int | gid_t * | - | - | - |
|
||||
| 81 | sys_setgroups | kernel/sys.c | int | gid_t * | - | - | - |
|
||||
|
||||
| 83 | sys_symlink | fs/namei.c | const char * | const char * | - | - | - |
|
||||
| 84 | sys_lstat | fs/stat.c | char * | struct __old_kernel_stat * | - | - | - |
|
||||
| 85 | sys_readlink | fs/stat.c | const char * | char * | int | - | - |
|
||||
| 86 | sys_uselib | fs/exec.c | const char * | - | - | - | - |
|
||||
| 87 | sys_swapon | mm/swapfile.c | const char * | int | - | - | - |
|
||||
| 88 | sys_reboot | kernel/sys.c | int | int | int | void * | - |
|
||||
| 89 | old_readdir | fs/readdir.c | unsigned int | void * | unsigned int | - | - |
|
||||
| 90 | old_mmap | arch/i386/kernel/sys_i386.c | struct mmap_arg_struct * | - | - | - | - |
|
||||
| 91 | sys_munmap | mm/mmap.c | unsigned long | size_t | - | - | - |
|
||||
| 92 | sys_truncate | fs/open.c | const char * | unsigned long | - | - | - |
|
||||
| 93 | sys_ftruncate | fs/open.c | unsigned int | unsigned long | - | - | - |
|
||||
| 94 | sys_fchmod | fs/open.c | unsigned int | mode_t | - | - | - |
|
||||
| 95 | sys_fchown | fs/open.c | unsigned int | uid_t | gid_t | - | - |
|
||||
| 96 | sys_getpriority | kernel/sys.c | int | int | - | - | - |
|
||||
| 97 | sys_setpriority | kernel/sys.c | int | int | int | - | - |
|
||||
| 99 | sys_statfs | fs/open.c | const char * | struct statfs * | - | - | - |
|
||||
| 100 | sys_fstatfs | fs/open.c | unsigned int | struct statfs * | - | - | - |
|
||||
| 101 | sys_ioperm | arch/i386/kernel/ioport.c | unsigned long | unsigned long | int | - | - |
|
||||
| 102 | sys_socketcall | net/socket.c | int | unsigned long * | - | - | - |
|
||||
| 103 | sys_syslog | kernel/printk.c | int | char * | int | - | - |
|
||||
| 104 | sys_setitimer | kernel/itimer.c | int | struct itimerval * | struct itimerval * | - | - |
|
||||
| 105 | sys_getitimer | kernel/itimer.c | int | struct itimerval * | - | - | - |
|
||||
| 106 | sys_newstat | fs/stat.c | char * | struct stat * | - | - | - |
|
||||
| 107 | sys_newlstat | fs/stat.c | char * | struct stat * | - | - | - |
|
||||
| 108 | sys_newfstat | fs/stat.c | unsigned int | struct stat * | - | - | - |
|
||||
| 109 | sys_uname | arch/i386/kernel/sys_i386.c | struct old_utsname * | - | - | - | - |
|
||||
| 110 | sys_iopl | arch/i386/kernel/ioport.c | unsigned long | - | - | - | - |
|
||||
| 111 | sys_vhangup | fs/open.c | - | - | - | - | - |
|
||||
| 112 | sys_idle | arch/i386/kernel/process.c | - | - | - | - | - |
|
||||
| 113 | sys_vm86old | arch/i386/kernel/vm86.c | unsigned long | struct vm86plus_struct * | - | - | - |
|
||||
| 114 | sys_wait4 | kernel/exit.c | pid_t | unsigned long * | int options | struct rusage * | - |
|
||||
| 115 | sys_swapoff | mm/swapfile.c | const char * | - | - | - | - |
|
||||
| 116 | sys_sysinfo | kernel/info.c | struct sysinfo * | - | - | - | - |
|
||||
| 117 | sys_ipc(*Note) | arch/i386/kernel/sys_i386.c | uint | int | int | int | void * |
|
||||
| 118 | sys_fsync | fs/buffer.c | unsigned int | - | - | - | - |
|
||||
| 119 | sys_sigreturn | arch/i386/kernel/signal.c | unsigned long | - | - | - | - |
|
||||
| 120 | sys_clone | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
| 121 | sys_setdomainname | kernel/sys.c | char * | int | - | - | - |
|
||||
| 122 | sys_newuname | kernel/sys.c | struct new_utsname * | - | - | - | - |
|
||||
| 123 | sys_modify_ldt | arch/i386/kernel/ldt.c | int | void * | unsigned long | - | - |
|
||||
| 124 | sys_adjtimex | kernel/time.c | struct timex * | - | - | - | - |
|
||||
| 125 | sys_mprotect | mm/mprotect.c | unsigned long | size_t | unsigned long | - | - |
|
||||
| 126 | sys_sigprocmask | kernel/signal.c | int | old_sigset_t * | old_sigset_t * | - | - |
|
||||
| 127 | sys_create_module | kernel/module.c | const char * | size_t | - | - | - |
|
||||
| 128 | sys_init_module | kernel/module.c | const char * | struct module * | - | - | - |
|
||||
| 129 | sys_delete_module | kernel/module.c | const char * | - | - | - | - |
|
||||
| 130 | sys_get_kernel_syms | kernel/module.c | struct kernel_sym * | - | - | - | - |
|
||||
| 131 | sys_quotactl | fs/dquot.c | int | const char * | int | caddr_t | - |
|
||||
| 132 | sys_getpgid | kernel/sys.c | pid_t | - | - | - | - |
|
||||
| 133 | sys_fchdir | fs/open.c | unsigned int | - | - | - | - |
|
||||
| 134 | sys_bdflush | fs/buffer.c | int | long | - | - | - |
|
||||
| 135 | sys_sysfs | fs/super.c | int | unsigned long | unsigned long | - | - |
|
||||
| 136 | sys_personality | kernel/exec_domain.c | unsigned long | - | - | - | - |
|
||||
| 138 | sys_setfsuid | kernel/sys.c | uid_t | - | - | - | - |
|
||||
| 139 | sys_setfsgid | kernel/sys.c | gid_t | - | - | - | - |
|
||||
| 140 | sys_llseek | fs/read_write.c | unsigned int | unsigned long | unsigned long | loff_t * | unsigned int |
|
||||
| 141 | sys_getdents | fs/readdir.c | unsigned int | void * | unsigned int | - | - |
|
||||
| 142 | sys_select | fs/select.c | int | fd_set * | fd_set * | fd_set * | struct timeval * |
|
||||
| 143 | sys_flock | fs/locks.c | unsigned int | unsigned int | - | - | - |
|
||||
| 144 | sys_msync | mm/filemap.c | unsigned long | size_t | int | - | - |
|
||||
| 145 | sys_readv | fs/read_write.c | unsigned long | const struct iovec * | unsigned long | - | - |
|
||||
| 146 | sys_writev | fs/read_write.c | unsigned long | const struct iovec * | unsigned long | - | - |
|
||||
| 147 | sys_getsid | kernel/sys.c | pid_t | - | - | - | - |
|
||||
| 148 | sys_fdatasync | fs/buffer.c | unsigned int | - | - | - | - |
|
||||
| 149 | sys_sysctl | kernel/sysctl.c | struct __sysctl_args * | - | - | - | - |
|
||||
| 150 | sys_mlock | mm/mlock.c | unsigned long | size_t | - | - | - |
|
||||
| 151 | sys_munlock | mm/mlock.c | unsigned long | size_t | - | - | - |
|
||||
| 152 | sys_mlockall | mm/mlock.c | int | - | - | - | - |
|
||||
| 153 | sys_munlockall | mm/mlock.c | - | - | - | - | - |
|
||||
| 154 | sys_sched_setparam | kernel/sched.c | pid_t | struct sched_param * | - | - | - |
|
||||
| 155 | sys_sched_getparam | kernel/sched.c | pid_t | struct sched_param * | - | - | - |
|
||||
| 156 | sys_sched_setscheduler | kernel/sched.c | pid_t | int | struct sched_param * | - | - |
|
||||
| 157 | sys_sched_getscheduler | kernel/sched.c | pid_t | - | - | - | - |
|
||||
| 158 | sys_sched_yield | kernel/sched.c | - | - | - | - | - |
|
||||
| 159 | sys_sched_get_priority_max | kernel/sched.c | int | - | - | - | - |
|
||||
| 160 | sys_sched_get_priority_min | kernel/sched.c | int | - | - | - | - |
|
||||
| 161 | sys_sched_rr_get_interval | kernel/sched.c | pid_t | struct timespec * | - | - | - |
|
||||
| 162 | sys_nanosleep | kernel/sched.c | struct timespec * | struct timespec * | - | - | - |
|
||||
| 163 | sys_mremap | mm/mremap.c | unsigned long | unsigned long | unsigned long | unsigned long | - |
|
||||
| 164 | sys_setresuid | kernel/sys.c | uid_t | uid_t | uid_t | - | - |
|
||||
| 165 | sys_getresuid | kernel/sys.c | uid_t * | uid_t * | uid_t * | - | - |
|
||||
| 166 | sys_vm86 | arch/i386/kernel/vm86.c | struct vm86_struct * | - | - | - | - |
|
||||
| 167 | sys_query_module | kernel/module.c | const char * | int | char * | size_t | size_t * |
|
||||
| 168 | sys_poll | fs/select.c | struct pollfd * | unsigned int | long | - | - |
|
||||
| 169 | sys_nfsservctl | fs/filesystems.c | int | void * | void * | - | - |
|
||||
| 170 | sys_setresgid | kernel/sys.c | gid_t | gid_t | gid_t | - | - |
|
||||
| 171 | sys_getresgid | kernel/sys.c | gid_t * | gid_t * | gid_t * | - | - |
|
||||
| 172 | sys_prctl | kernel/sys.c | int | unsigned long | unsigned long | unsigned long | unsigned long |
|
||||
| 173 | sys_rt_sigreturn | arch/i386/kernel/signal.c | unsigned long | - | - | - | - |
|
||||
| 174 | sys_rt_sigaction | kernel/signal.c | int | const struct sigaction * | struct sigaction * | size_t | - |
|
||||
| 175 | sys_rt_sigprocmask | kernel/signal.c | int | sigset_t * | sigset_t * | size_t | - |
|
||||
| 176 | sys_rt_sigpending | kernel/signal.c | sigset_t * | size_t | - | - | - |
|
||||
| 177 | sys_rt_sigtimedwait | kernel/signal.c | const sigset_t * | siginfo_t * | const struct timespec * | size_t | - |
|
||||
| 178 | sys_rt_sigqueueinfo | kernel/signal.c | int | int | siginfo_t * | - | - |
|
||||
| 179 | sys_rt_sigsuspend | arch/i386/kernel/signal.c | sigset_t * | size_t | - | - | - |
|
||||
| 180 | sys_pread | fs/read_write.c | unsigned int | char * | size_t | loff_t | - |
|
||||
| 181 | sys_pwrite | fs/read_write.c | unsigned int | const char * | size_t | loff_t | - |
|
||||
| 182 | sys_chown | fs/open.c | const char * | uid_t | gid_t | - | - |
|
||||
| 183 | sys_getcwd | fs/dcache.c | char * | unsigned long | - | - | - |
|
||||
| 184 | sys_capget | kernel/capability.c | cap_user_header_t | cap_user_data_t | - | - | - |
|
||||
| 185 | sys_capset | kernel/capability.c | cap_user_header_t | const cap_user_data_t | - | - | - |
|
||||
| 186 | sys_sigaltstack | arch/i386/kernel/signal.c | const stack_t * | stack_t * | - | - | - |
|
||||
| 187 | sys_sendfile | mm/filemap.c | int | int | off_t * | size_t | - |
|
||||
| 190 | sys_vfork | arch/i386/kernel/process.c | struct pt_regs | - | - | - | - |
|
||||
| | | | | | | | |
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
MentOS 0.1
|
||||
MentOS 0.6.0
|
||||
|
||||
Welcome to the MentOS, the Mentoring Operating System.
|
||||
|
||||
If you want some help enter the "help" command into the cli.
|
||||
If you want some help enter the "man" command into the cli.
|
||||
|
||||
Bye,
|
||||
The Ment(OS) Team
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
root:x:0:user,root,marco
|
||||
user:x:1000:banana,marco
|
||||
@@ -0,0 +1 @@
|
||||
avalon
|
||||
@@ -0,0 +1 @@
|
||||
Call `man` to have a list of all the commands.
|
||||
@@ -0,0 +1,2 @@
|
||||
root:root:0:0:Root User:/root:/bin/shell
|
||||
user:user:1000:1000:Normal User:/home/user:/bin/shell
|
||||
@@ -1 +0,0 @@
|
||||
io ti vi bi!
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../README
|
||||
@@ -1 +0,0 @@
|
||||
tanto questa e' solo una prova :\
|
||||
@@ -1,3 +0,0 @@
|
||||
root:password
|
||||
user:computer
|
||||
asd:asd
|
||||
@@ -1,28 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
void main(int argc, char ** argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
// Try to open the file.
|
||||
int fd = open(argv[1], O_RDONLY, 42);
|
||||
if (fd > -1)
|
||||
{
|
||||
char c;
|
||||
// Put on the standard output the characters.
|
||||
while (read(fd, &c, 1)) putchar(c);
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s: cannot find the file.\n\n", argv[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Usage: more file\n\n");
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
ciao mondo
|
||||
@@ -1 +0,0 @@
|
||||
come va ?
|
||||
@@ -1 +0,0 @@
|
||||
bho, io credo bene eh eh eh
|
||||
@@ -1 +0,0 @@
|
||||
tanto questa e' solo una prova :\
|
||||
@@ -1 +0,0 @@
|
||||
io ti vi bi!
|
||||
@@ -0,0 +1,8 @@
|
||||
SYNOPSIS
|
||||
cat [FILE]
|
||||
|
||||
DESCRIPTION
|
||||
Prints the content of the given file.
|
||||
|
||||
OPTIONS
|
||||
-h --help : shows command help.
|
||||
@@ -0,0 +1,5 @@
|
||||
SYNOPSIS
|
||||
clear
|
||||
|
||||
DESCRIPTION
|
||||
Clears the screen.
|
||||
@@ -0,0 +1,5 @@
|
||||
SYNOPSIS
|
||||
cpuid
|
||||
|
||||
DESCRIPTION
|
||||
Not currently implemented.
|
||||
@@ -0,0 +1,5 @@
|
||||
SYNOPSIS
|
||||
date
|
||||
|
||||
DESCRIPTION
|
||||
Shows the current date.
|
||||
@@ -0,0 +1,6 @@
|
||||
SYNOPSIS
|
||||
echo [STRING]
|
||||
|
||||
DESCRIPTION
|
||||
Displays a line of text.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
SYNOPSIS
|
||||
ipcs [options]
|
||||
|
||||
DESCRIPTION
|
||||
Ipcs shows information on System V inter-process communication facilities.
|
||||
@@ -0,0 +1,12 @@
|
||||
SYNOPSIS
|
||||
ls [OPTIONS] [FILE/FOLDER]
|
||||
|
||||
DESCRIPTION
|
||||
List information about the given file, or the files contained in the given
|
||||
folder. If not argument is provided it will list information about files
|
||||
inside the current folder.
|
||||
|
||||
OPTIONS
|
||||
-h --help : shows command help.
|
||||
-a --all : list all entries.
|
||||
-l --long : show the entries as a detailed long list.
|
||||
@@ -0,0 +1,12 @@
|
||||
SYNOPSIS
|
||||
start [OPTIONS] [FILE]
|
||||
|
||||
DESCRIPTION
|
||||
Start a recording session aimed at displaying an ordered list of 50 items
|
||||
containing information about the processes that the CPU has just processed.
|
||||
|
||||
|
||||
OPTIONS
|
||||
-h: shows command help. //non funziona per ora lol
|
||||
-p: start the session with generated children
|
||||
-f [FILE]: start the session launching a specified program
|
||||
@@ -1,34 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Initialize the project.
|
||||
project(initfscp C ASM)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Set the project name.
|
||||
set(PROJECT_NAME initfscp)
|
||||
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_C_COMPILER gcc)
|
||||
set(CMAKE_CXX_COMPILER g++)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "")
|
||||
endif (CMAKE_CROSSCOMPILING)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Set the compiler options (original).
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the includes.
|
||||
include_directories(inc)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the source files.
|
||||
set(SOURCE_FILES src/initfscp.c)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add the executable.
|
||||
add_executable(initfscp ${SOURCE_FILES})
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
----
|
||||
README
|
||||
initfscp - Autore di questa guida: Aleksej
|
||||
----
|
||||
|
||||
initfscp e' un programma che serve a creare un'immagine contenente il file system utilizzato da MentOS.
|
||||
Consente di inserirci dei files e/o dei mountpoint (massimo 32) all'interno.
|
||||
Per far ciò digitare il comando "initfscp [-m mountpoint1 -m mountpoint2 ... -m mountpoint n] file1 file2 ... nomefs"
|
||||
|
||||
dove:
|
||||
- -m mountpoint1 -m mountpoint2 ... -m mountpoint n (facoltativo) indicano i mountpoint da inserire nel filesystem appena creato.
|
||||
- "file1 file2 ..." sono i files che inseriremo nel filesystem,
|
||||
- "nomefs" è il nome che daremo all'immagine.
|
||||
Ad esempio vogliamo inserire i file topolino, pippo e paperino nell'immagine che chiameremo disney, quindi digitiamo:
|
||||
initfscp topolino pippo paperino disney
|
||||
così facendo initfscp genererà l'immagine disney.
|
||||
|
||||
Altri comandi disponibili:
|
||||
--help (-h) per visualizzare una guida più sintetica.
|
||||
--version (-v) per visualizzare la versione utilizzata attualmente di initfscp.
|
||||
@@ -1,42 +0,0 @@
|
||||
/// @file initfscp.h
|
||||
/// @brief
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MAX_FILENAME_LENGTH 64
|
||||
#define MAX_FILES 32
|
||||
#define INITFSCP_VER "0.3.0"
|
||||
|
||||
#define FS_FILE 0x01 ///< Identifies a file.
|
||||
#define FS_DIRECTORY 0x02 ///< Identifies a directory.
|
||||
#define FS_CHARDEVICE 0x04 ///< Identifies a character devies.
|
||||
#define FS_BLOCKDEVICE 0x08 ///< Identifies a block devies.
|
||||
#define FS_PIPE 0x10 ///< Identifies a pipe.
|
||||
#define FS_SYMLINK 0x20 ///< Identifies a symbolic link.
|
||||
#define FS_MOUNTPOINT 0x40 ///< Identifies a mount-point.
|
||||
|
||||
#define RESET "\033[00m"
|
||||
#define BLACK "\033[30m"
|
||||
#define RED "\033[31m"
|
||||
#define GREEN "\033[32m"
|
||||
#define YELLOW "\033[33m"
|
||||
#define BLUE "\033[34m"
|
||||
#define MAGENTA "\033[35m"
|
||||
#define CYAN "\033[36m"
|
||||
#define WHITE "\033[37m"
|
||||
|
||||
/// @brief Information concerning a file.
|
||||
typedef struct initrd_file_t {
|
||||
/// Number used as delimiter, it must be set to 0xBF.
|
||||
int magic;
|
||||
/// The name of the file.
|
||||
char fileName[MAX_FILENAME_LENGTH];
|
||||
/// The type of the file.
|
||||
short int file_type;
|
||||
/// The uid of the owner.
|
||||
int uid;
|
||||
/// Offset of the starting address.
|
||||
unsigned int offset;
|
||||
/// Dimension of the file.
|
||||
unsigned int length;
|
||||
} initrd_file_t;
|
||||
@@ -1,324 +0,0 @@
|
||||
/// @file initfscp.c
|
||||
/// @brief
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <initfscp.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
#include <assert.h>
|
||||
|
||||
static FILE *target_fs = NULL;
|
||||
static initrd_file_t headers[MAX_FILES];
|
||||
static char mount_points[MAX_FILES][MAX_FILENAME_LENGTH];
|
||||
static int mountpoint_idx = 0;
|
||||
static int header_idx = 0;
|
||||
static int header_offset = 0;
|
||||
|
||||
static inline void usage(char *prgname)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" %s --help For this screen\n", prgname);
|
||||
printf(" %s --source [-s] The source directory.\n", prgname);
|
||||
printf(" %s --target [-t] The target file for the initfs.\n", prgname);
|
||||
}
|
||||
|
||||
static inline void version(char *prgname)
|
||||
{
|
||||
printf("%s version: %s\n", prgname, INITFSCP_VER);
|
||||
}
|
||||
|
||||
static inline bool is_option_mount_point(char *arg)
|
||||
{
|
||||
if (arg == NULL)
|
||||
return false;
|
||||
return ((strcmp(arg, "-m") == 0) || (strcmp(arg, "--mountpoint") == 0));
|
||||
}
|
||||
|
||||
static inline bool is_option_source(char *arg)
|
||||
{
|
||||
if (arg == NULL)
|
||||
return false;
|
||||
return ((strcmp(arg, "-s") == 0) || (strcmp(arg, "--source") == 0));
|
||||
}
|
||||
|
||||
static inline bool is_option_target(char *arg)
|
||||
{
|
||||
if (arg == NULL)
|
||||
return false;
|
||||
return ((strcmp(arg, "-t") == 0) || (strcmp(arg, "--target") == 0));
|
||||
}
|
||||
|
||||
static inline bool is_mount_point(char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return false;
|
||||
// Check if the name matches with a mount-point.
|
||||
for (int i = 0; i < mountpoint_idx; ++i) {
|
||||
if (strcmp(name, mount_points[i]) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static FILE *openfile(const char *dirname, struct dirent *dir, const char *mode)
|
||||
{
|
||||
char pathname[1024];
|
||||
FILE *fp;
|
||||
sprintf(pathname, "%s/%s", dirname, dir->d_name);
|
||||
fp = fopen(pathname, mode);
|
||||
return fp;
|
||||
}
|
||||
|
||||
static bool open_target_fs(int argc, char *argv[])
|
||||
{
|
||||
printf("%-64s", "Opening target filesystem...");
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (is_option_target(argv[i]) && ((i + 1) < argc)) {
|
||||
target_fs = fopen(argv[i + 1], "w");
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
printf("[" RED "FAILED" RESET "]\n\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool init_headers()
|
||||
{
|
||||
printf("%-64s", "Initializing headers structures...");
|
||||
for (size_t i = 0; i < MAX_FILES; i++) {
|
||||
headers[i].magic = 0xBF;
|
||||
memset(headers[i].fileName, 0, MAX_FILENAME_LENGTH);
|
||||
headers[i].file_type = 0;
|
||||
headers[i].uid = 0;
|
||||
headers[i].offset = 0;
|
||||
headers[i].length = 0;
|
||||
}
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool init_mount_points(int argc, char *argv[])
|
||||
{
|
||||
printf("Initializing mount points...\n");
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (is_option_mount_point(argv[i]) && ((i + 1) < argc)) {
|
||||
strcpy(mount_points[mountpoint_idx], argv[i + 1]);
|
||||
printf("[%3d] MPNT: %-52s", mountpoint_idx,
|
||||
mount_points[mountpoint_idx]);
|
||||
printf("[" CYAN "DONE" RESET "]\n");
|
||||
++mountpoint_idx;
|
||||
}
|
||||
}
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool create_file_headers(char *mountpoint, char *directory)
|
||||
{
|
||||
assert(mountpoint && "Received null mountpoint.");
|
||||
assert(directory && "Received null directory.");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
char absolute_path[256];
|
||||
memset(absolute_path, 0, 256);
|
||||
strcpy(absolute_path, mountpoint);
|
||||
strcat(absolute_path, directory);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
DIR *source_dir = opendir(absolute_path);
|
||||
if (source_dir == NULL) {
|
||||
printf("[" RED "FAILED" RESET "]\n");
|
||||
printf("Could not open source directory %s.\n", absolute_path);
|
||||
return false;
|
||||
}
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(source_dir)) != NULL) {
|
||||
if ((strcmp(entry->d_name, ".") == 0) ||
|
||||
(strcmp(entry->d_name, "..") == 0)) {
|
||||
continue;
|
||||
}
|
||||
if (entry->d_type != DT_DIR) {
|
||||
char relative_filename[256];
|
||||
strcpy(relative_filename, directory);
|
||||
strcat(relative_filename, "/");
|
||||
strcat(relative_filename, entry->d_name);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
FILE *fd = openfile(absolute_path, entry, "r+");
|
||||
printf("[%3d] FILE: %-52s", header_idx, relative_filename);
|
||||
if (fd == NULL) {
|
||||
printf("[" RED "FAILED" RESET "]\n");
|
||||
printf("Error while opening file : %s\n", relative_filename);
|
||||
}
|
||||
fseek(fd, 0, SEEK_END);
|
||||
long length = ftell(fd);
|
||||
fclose(fd);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
strcpy(headers[header_idx].fileName, relative_filename);
|
||||
headers[header_idx].file_type = FS_FILE;
|
||||
headers[header_idx].length = length;
|
||||
headers[header_idx].offset = header_offset;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
printf("[" BLUE "OPEN" RESET "]");
|
||||
printf("[OFFSET:%6d]", headers[header_idx].offset);
|
||||
printf("[SIZE:%6d]", headers[header_idx].length);
|
||||
printf("[" GREEN "DONE" RESET "]\n");
|
||||
|
||||
header_offset += headers[header_idx].length;
|
||||
++header_idx;
|
||||
} else {
|
||||
// ----------------------------------------------------------------
|
||||
char sub_directory[256];
|
||||
memset(sub_directory, 0, 256);
|
||||
strcpy(sub_directory, directory);
|
||||
strcat(sub_directory, "/");
|
||||
strcat(sub_directory, entry->d_name);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
strcpy(headers[header_idx].fileName, sub_directory);
|
||||
headers[header_idx].file_type = FS_DIRECTORY;
|
||||
headers[header_idx].length = 0;
|
||||
headers[header_idx].offset = 0 /*++header_offset*/;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Check if the directory is a mountpoint.
|
||||
if (is_mount_point(headers[header_idx].fileName)) {
|
||||
headers[header_idx].file_type = FS_MOUNTPOINT;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
printf("[%3d] %3s : %-52s", header_idx,
|
||||
(headers[header_idx].file_type == FS_DIRECTORY) ? "DIR" :
|
||||
"MPT",
|
||||
sub_directory);
|
||||
printf("[" BLUE "OPEN" RESET "]");
|
||||
printf("[OFFSET:%6d]", headers[header_idx].offset);
|
||||
printf("[SIZE:%6d]", headers[header_idx].length);
|
||||
printf("[" GREEN "DONE" RESET "]\n");
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
++header_idx;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
create_file_headers(mountpoint, sub_directory);
|
||||
}
|
||||
}
|
||||
closedir(source_dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool write_file_system(char *mountpoint)
|
||||
{
|
||||
printf("Copying data to filesystem...\n");
|
||||
for (int i = 0; i < MAX_FILES; i++) {
|
||||
// --------------------------------------------------------------------
|
||||
char absolute_path[256];
|
||||
memset(absolute_path, 0, 256);
|
||||
strcpy(absolute_path, mountpoint);
|
||||
strcat(absolute_path, headers[i].fileName);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
if (headers[i].file_type == FS_FILE) {
|
||||
FILE *fd2 = fopen(absolute_path, "r+");
|
||||
if (fd2 == NULL) {
|
||||
continue;
|
||||
}
|
||||
printf("[%3d] FILE: %-92s", i, absolute_path);
|
||||
char *buffer = (char *)malloc(headers[i].length);
|
||||
fread(buffer, 1, headers[i].length, fd2);
|
||||
fwrite(buffer, 1, headers[i].length, target_fs);
|
||||
printf("[" GREEN "DONE" RESET "]\n");
|
||||
fclose(fd2);
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Welcome to MentOS initfs file copier tool\n\n");
|
||||
if (argc <= 1) {
|
||||
if (argv[0][0] == '.') {
|
||||
version(argv[0] + 2);
|
||||
}
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
|
||||
version(argv[0] + 2);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
||||
usage(argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Open the fs.
|
||||
if (!open_target_fs(argc, argv)) {
|
||||
printf("Could not open target FileSystem.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Initialize the headers.
|
||||
if (!init_headers()) {
|
||||
printf("Could not initialize headers.\n");
|
||||
fclose(target_fs);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Initialize the mountpoints.
|
||||
if (!init_mount_points(argc, argv)) {
|
||||
printf("Could not initialize mount points.\n");
|
||||
fclose(target_fs);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Create file headers.
|
||||
header_offset = sizeof(struct initrd_file_t) * MAX_FILES + sizeof(int);
|
||||
printf("Creating headers...\n");
|
||||
for (uint32_t i = 1; i < argc; ++i) {
|
||||
if (is_option_source(argv[i]) && ((i + 1) < argc)) {
|
||||
if (!create_file_headers(argv[i + 1], "")) {
|
||||
printf("Could not create file headers.\n");
|
||||
fclose(target_fs);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Copying information about headers on filesystem.
|
||||
printf("%-64s", "Copying information about headers to filesystem...");
|
||||
fwrite(&header_idx, sizeof(int), 1, target_fs);
|
||||
fwrite(headers, sizeof(struct initrd_file_t), 32, target_fs);
|
||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Write headers on filesystem.
|
||||
for (uint32_t i = 1; i < argc; ++i) {
|
||||
if (is_option_source(argv[i]) && ((i + 1) < argc)) {
|
||||
if (!write_file_system(argv[i + 1])) {
|
||||
printf("Could not write on filesystem.\n");
|
||||
fclose(target_fs);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(target_fs);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
set timeout=5
|
||||
set default=0
|
||||
|
||||
menuentry "MentOS" {
|
||||
multiboot /boot/kernel-bootloader.bin
|
||||
boot
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
# =============================================================================
|
||||
# LIBRARY
|
||||
# =============================================================================
|
||||
|
||||
# Add the library.
|
||||
add_library(
|
||||
libc
|
||||
${CMAKE_SOURCE_DIR}/libc/src/stdio.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/ctype.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/string.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/stdlib.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/math.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/fcvt.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/time.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/strerror.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/termios.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/libgen.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/vsprintf.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/vscanf.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/pwd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/grp.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sched.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/readline.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/setenv.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/assert.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/abort.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/io/mm_io.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/io/debug.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/ipc.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/unistd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/errno.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/utsname.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/mman.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/sys/ioctl.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/creat.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getppid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/exit.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setsid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getsid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setpgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getgid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/setuid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getuid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/fork.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/read.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/write.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/exec.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/nice.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/open.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/reboot.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/waitpid.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/chdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getcwd.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/close.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/stat.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/rmdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/mkdir.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/unlink.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/getdents.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/lseek.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/kill.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/signal.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/interval.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/symlink.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/unistd/readlink.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/libc_start.c
|
||||
${CMAKE_SOURCE_DIR}/libc/src/crt0.S
|
||||
)
|
||||
|
||||
# Add the includes.
|
||||
target_include_directories(libc PUBLIC inc)
|
||||
|
||||
# Remove the 'lib' prefix.
|
||||
set_target_properties(libc PROPERTIES PREFIX "")
|
||||
@@ -0,0 +1,38 @@
|
||||
/// @file array.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/// Function for allocating memory for the array.
|
||||
#define ARRAY_ALLOC kmalloc
|
||||
/// Function for freeing the memory for the array.
|
||||
#define ARRAY_FREE kfree
|
||||
#else
|
||||
/// Function for allocating memory for the array.
|
||||
#define ARRAY_ALLOC malloc
|
||||
/// Function for freeing the memory for the array.
|
||||
#define ARRAY_FREE free
|
||||
#endif
|
||||
|
||||
/// @brief Declares a new dynamic-size array structure.
|
||||
#define DECLARE_ARRAY(type, name) \
|
||||
typedef struct arr_##name##_t { \
|
||||
const unsigned size; \
|
||||
type *buffer; \
|
||||
} arr_##name##_t; \
|
||||
arr_##name##_t alloc_arr_##name(unsigned len) \
|
||||
{ \
|
||||
arr_##name##_t a = { len, len > 0 ? ARRAY_ALLOC(sizeof(type) * len) : NULL }; \
|
||||
memset(a.buffer, 0, sizeof(type) * len); \
|
||||
return a; \
|
||||
} \
|
||||
static inline void free_arr_##name(arr_##name##_t *arr) \
|
||||
{ \
|
||||
ARRAY_FREE(arr->buffer); \
|
||||
}
|
||||
|
||||
#undef ARRAY_ALLOC
|
||||
#undef ARRAY_FREE
|
||||
@@ -0,0 +1,19 @@
|
||||
/// @file assert.h
|
||||
/// @brief Defines the function and pre-processor macro for assertions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Function used to log the information of a failed assertion.
|
||||
/// @param assertion The failed assertion.
|
||||
/// @param file The file where the assertion is located.
|
||||
/// @param function The function where the assertion is.
|
||||
/// @param line The line inside the file.
|
||||
void __assert_fail(const char *assertion, const char *file, const char *function, unsigned int line);
|
||||
|
||||
/// @brief Extract the filename from the full path provided by __FILE__.
|
||||
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
/// @brief Assert function.
|
||||
#define assert(expression) ((expression) ? (void)0 : __assert_fail(#expression, __FILENAME__, __func__, __LINE__))
|
||||
@@ -0,0 +1,9 @@
|
||||
/// @file ioctls.h
|
||||
/// @brief Input/Output ConTroL (IOCTL) numbers.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TCGETS 0x5401U ///< Get the current serial port settings.
|
||||
#define TCSETS 0x5402U ///< Set the current serial port settings.
|
||||
@@ -0,0 +1,35 @@
|
||||
/// @file stat.h
|
||||
/// @brief Defines the structure used by the functiosn fstat(), lstat(), and stat().
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__SYS_STAT_H) && !defined(__KERNEL__)
|
||||
#error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
|
||||
#endif
|
||||
|
||||
#include "stddef.h"
|
||||
#include "time.h"
|
||||
|
||||
/// @brief Data structure which contains information about a file.
|
||||
typedef struct stat_t {
|
||||
/// ID of device containing file.
|
||||
dev_t st_dev;
|
||||
/// File serial number.
|
||||
ino_t st_ino;
|
||||
/// Mode of file.
|
||||
mode_t st_mode;
|
||||
/// File user id.
|
||||
uid_t st_uid;
|
||||
/// File group id.
|
||||
gid_t st_gid;
|
||||
/// File Size.
|
||||
off_t st_size;
|
||||
/// Time of last access.
|
||||
time_t st_atime;
|
||||
/// Time of last data modification.
|
||||
time_t st_mtime;
|
||||
/// Time of last status change.
|
||||
time_t st_ctime;
|
||||
} stat_t;
|
||||
@@ -0,0 +1,46 @@
|
||||
/// @file termios-struct.h
|
||||
/// @brief Definition of the `termios` structure.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Type for control characters.
|
||||
typedef unsigned char cc_t;
|
||||
/// Type for speed.
|
||||
typedef unsigned int speed_t;
|
||||
/// Type for flags.
|
||||
typedef unsigned int tcflag_t;
|
||||
/// The number of control characters.
|
||||
#define NCCS 32
|
||||
|
||||
/// @brief Stores information about a terminal IOs.
|
||||
typedef struct termios {
|
||||
tcflag_t c_iflag; ///< input mode flags
|
||||
tcflag_t c_oflag; ///< output mode flags
|
||||
tcflag_t c_cflag; ///< control mode flags
|
||||
tcflag_t c_lflag; ///< local mode flags
|
||||
cc_t c_line; ///< line discipline
|
||||
cc_t c_cc[NCCS]; ///< control characters
|
||||
speed_t c_ispeed; ///< input speed
|
||||
speed_t c_ospeed; ///< output speed
|
||||
} termios_t;
|
||||
|
||||
//These flags generally control higher-level aspects of input processing than
|
||||
// the input modes flags described in Input Modes, such as echoing, signals, and
|
||||
// the choice of canonical or noncanonical input.
|
||||
|
||||
#define ISIG 0x00000080 ///< Controls whether the INTR, QUIT, and SUSP characters are recognized.
|
||||
#define ICANON 0x00000100 ///< Enables canonical input processing mode.
|
||||
#define ECHO 0x00000008 ///< Echo input characters.
|
||||
#define ECHOE 0x00000002 ///< If ICANON is set, the ERASE character erases the preceding character.
|
||||
#define ECHOK 0x00000004 ///< If ICANON is set, the KILL character erases the current line.
|
||||
#define ECHONL 0x00000010 ///< If ICANON is set, echo the NL character even if ECHO is not set.
|
||||
#define NOFLSH 0x80000000 ///< Do not clear in/out queues when receiving INTR, QUIT, and SUSP.
|
||||
#define TOSTOP 0x00400000 ///< Allows SIGTTOU signals generated by background processes.
|
||||
#define ECHOCTL 0x00000040 ///< If this and ECHO are set, control characters with ‘^’ are echoed.
|
||||
#define ECHOKE 0x00000001 ///< If ICANON is set, KILL is echoed by erasing each character on the line.
|
||||
#define IEXTEN 0x00000400 ///< Enables implementation-defined input processing.
|
||||
|
||||
/// @brief Mask for extracting control values.
|
||||
#define CTRL(x) ((x) & 037)
|
||||
@@ -0,0 +1,56 @@
|
||||
/// @file ctype.h
|
||||
/// @brief Functions related to character handling.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Check if the given value is a digit.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isdigit(int c);
|
||||
|
||||
/// @brief Check if the given value is a letter.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isalpha(int c);
|
||||
|
||||
/// @brief Check if the given value is a control character.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int iscntrl(int c);
|
||||
|
||||
/// @brief Check if the given value is either a letter or a digit.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isalnum(int c);
|
||||
|
||||
/// @brief Check if the given value is an hexadecimal digit.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isxdigit(int c);
|
||||
|
||||
/// @brief Check if the given value is a lower case letter.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int islower(int c);
|
||||
|
||||
/// @brief Check if the given value is an upper case letter.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isupper(int c);
|
||||
|
||||
/// @brief Transforms the given value into a lower case letter.
|
||||
/// @param c The input letter.
|
||||
/// @return The input letter turned into a lower case letter.
|
||||
int tolower(int c);
|
||||
|
||||
/// @brief Transforms the given value into an upper case letter.
|
||||
/// @param c The input letter.
|
||||
/// @return The input letter turned into an upper case letter.
|
||||
int toupper(int c);
|
||||
|
||||
/// @brief Check if the given value is a whitespace.
|
||||
/// @param c The input character.
|
||||
/// @return 1 on success, 0 otherwise.
|
||||
int isspace(int c);
|
||||
@@ -0,0 +1,46 @@
|
||||
/// @file fcntl.h
|
||||
/// @brief Headers of functions fcntl() and open().
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define O_RDONLY 00000000U ///< Open for reading only.
|
||||
#define O_WRONLY 00000001U ///< Open for writing only.
|
||||
#define O_RDWR 00000002U ///< Open for reading and writing.
|
||||
#define O_CREAT 00000100U ///< Create if nonexistant.
|
||||
#define O_EXCL 00000200U ///< Error if already exists.
|
||||
#define O_TRUNC 00001000U ///< Truncate to zero length.
|
||||
#define O_APPEND 00002000U ///< Set append mode.
|
||||
#define O_NONBLOCK 00004000U ///< No delay.
|
||||
#define O_DIRECTORY 00200000U ///< If file exists has no effect. Otherwise, the file is created.
|
||||
|
||||
/// @defgroup ModeBitsAccessPermission Mode Bits for Access Permission
|
||||
/// @brief The file modes.
|
||||
/// @{
|
||||
|
||||
#define S_ISUID 0x0800 ///< Set user id on execution
|
||||
#define S_ISGID 0x0400 ///< Set group id on execution
|
||||
#define S_ISVTX 0x0200 ///< Save swapped text even after use (Sticky Bit)
|
||||
#define S_IRWXU 0x01C0 ///< rwx------ : User can read/write/execute
|
||||
#define S_IRUSR 0x0100 ///< r-------- : User can read
|
||||
#define S_IWUSR 0x0080 ///< -w------- : User can write
|
||||
#define S_IXUSR 0x0040 ///< --x------ : User can execute
|
||||
#define S_IRWXG 0x0038 ///< ---rwx--- : Group can read/write/execute
|
||||
#define S_IRGRP 0x0020 ///< ---r----- : Group can read
|
||||
#define S_IWGRP 0x0010 ///< ----w---- : Group can write
|
||||
#define S_IXGRP 0x0008 ///< -----x--- : Group can execute
|
||||
#define S_IRWXO 0x0007 ///< ------rwx : Others can read/write/execute
|
||||
#define S_IROTH 0x0004 ///< ------r-- : Others can read
|
||||
#define S_IWOTH 0x0002 ///< -------w- : Others can write
|
||||
#define S_IXOTH 0x0001 ///< --------x : Others can execute
|
||||
|
||||
#define S_ISDIR(m) (((m)&0170000) == 0040000) ///< directory.
|
||||
#define S_ISCHR(m) (((m)&0170000) == 0020000) ///< char special
|
||||
#define S_ISBLK(m) (((m)&0170000) == 0060000) ///< block special
|
||||
#define S_ISREG(m) (((m)&0170000) == 0100000) ///< regular file
|
||||
#define S_ISFIFO(m) (((m)&0170000) == 0010000) ///< fifo
|
||||
#define S_ISLNK(m) (((m)&0170000) == 0120000) ///< symbolic link
|
||||
#define S_ISSOCK(m) (((m)&0170000) == 0140000) ///< socket
|
||||
|
||||
/// @}
|
||||
@@ -0,0 +1,36 @@
|
||||
/// @file fcvt.h
|
||||
/// @brief Declare the functions required to turn double values into a string.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Thif function transforms `value` into a string of digits inside `buf`,
|
||||
/// representing the whole part followed by the decimal part.
|
||||
/// @details
|
||||
/// For instance, 512.765 will result in:
|
||||
/// decpt = 3
|
||||
/// sign = 0
|
||||
/// buf = "512765"
|
||||
/// @param arg The argument to turn into string.
|
||||
/// @param chars The total number of digits.
|
||||
/// @param decpt The position of the decimal point.
|
||||
/// @param sign The sign of the number.
|
||||
/// @param buf Buffer where the digits should be placed.
|
||||
/// @param buf_size Dimension of the buffer.
|
||||
void ecvtbuf(double arg, int chars, int *decpt, int *sign, char *buf, unsigned buf_size);
|
||||
|
||||
/// @brief Thif function transforms `value` into a string of digits inside `buf`,
|
||||
/// representing the whole part followed by the decimal part.
|
||||
/// @details
|
||||
/// For instance, 512.765 will result in:
|
||||
/// decpt = 3
|
||||
/// sign = 0
|
||||
/// buf = "512765"
|
||||
/// @param arg The argument to turn into string.
|
||||
/// @param decimals The total number of digits to write after the decimal point.
|
||||
/// @param decpt The position of the decimal point.
|
||||
/// @param sign The sign of the number.
|
||||
/// @param buf Buffer where the digits should be placed.
|
||||
/// @param buf_size Dimension of the buffer.
|
||||
void fcvtbuf(double arg, int decimals, int *decpt, int *sign, char *buf, unsigned buf_size);
|
||||
@@ -0,0 +1,72 @@
|
||||
/// @file grp.h
|
||||
/// @brief Defines the structures and functions for managing groups.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// Maximum number of users per group
|
||||
#define MAX_MEMBERS_PER_GROUP 64
|
||||
|
||||
/// @brief Contains user group informations.
|
||||
typedef struct group {
|
||||
/// The name of the group.
|
||||
char *gr_name;
|
||||
/// Encrypted password.
|
||||
char *gr_passwd;
|
||||
/// Group ID.
|
||||
gid_t gr_gid;
|
||||
/// List of group members.
|
||||
char *gr_mem[MAX_MEMBERS_PER_GROUP + 1];
|
||||
} group_t;
|
||||
|
||||
/// @brief Provides access to the group database entry for `uid`.
|
||||
/// @param gid The gid to search inside the database.
|
||||
/// @return A pointer to the structure containing the database entry.
|
||||
group_t *getgrgid(gid_t gid);
|
||||
|
||||
/// @brief Provides access to the group database entry for `name`.
|
||||
/// @param name The name to search inside the database.
|
||||
/// @return A pointer to the structure containing the database entry.
|
||||
group_t *getgrnam(const char *name);
|
||||
|
||||
/// @brief Provides the same information as getgrgid but it stores the results
|
||||
/// inside group, and the string information are store store inside `buf`.
|
||||
/// @param gid The uid to search inside the database.
|
||||
/// @param group The structure containing pointers to the entry fields.
|
||||
/// @param buf The buffer where the strings should be stored.
|
||||
/// @param buflen The lenght of the buffer.
|
||||
/// @param result A pointer to the result or NULL is stored here.
|
||||
/// @return If the entry was found returns zero and set *result to group, if the
|
||||
/// entry was not found returns zero and set *result to NULL, on failure returns
|
||||
/// a number and sets and set *result to NULL.
|
||||
int getgrgid_r(gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result);
|
||||
|
||||
/// @brief Provides the same information as getgrnam but it stores the results
|
||||
///inside group, and the string information are store store inside `buf`.
|
||||
/// @param name The name to search inside the database.
|
||||
/// @param group The structure containing pointers to the entry fields.
|
||||
/// @param buf The buffer where the strings should be stored.
|
||||
/// @param buflen The lenght of the buffer.
|
||||
/// @param result A pointer to the result or NULL is stored here.
|
||||
/// @return If the entry was found returns zero and set *result to group, if the
|
||||
/// entry was not found returns zero and set *result to NULL, on failure returns
|
||||
/// a number and sets and set *result to NULL.
|
||||
int getgrnam_r(const char *name, group_t *group, char *buf, size_t buflen, group_t **result);
|
||||
|
||||
/// @brief Returns a pointer to a structure containing the broken-out fields of
|
||||
/// an entry in the group database.
|
||||
/// @return pointer to the group entry.
|
||||
/// @details When first called returns a pointer to a group structure containing
|
||||
/// the first entry in the group database. Thereafter, it returns a pointer to a
|
||||
/// group structure containing the next group structure in the group database,
|
||||
/// so successive calls may be used to search the entire database.
|
||||
group_t *getgrent(void);
|
||||
|
||||
/// @brief Rewinds the group database to allow repeated searches.
|
||||
void endgrent(void);
|
||||
|
||||
/// @brief May be called to close the group database when processing is complete.
|
||||
void setgrent(void);
|
||||
@@ -0,0 +1,62 @@
|
||||
/// @file ansi_colors.h
|
||||
/// @brief List of ANSI colors.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FG_RESET "\033[0m" ///< ANSI code for resetting.
|
||||
|
||||
#define FG_BLACK "\033[30m" ///< ANSI code for setting a BLACK foreground.
|
||||
#define FG_RED "\033[31m" ///< ANSI code for setting a RED foreground.
|
||||
#define FG_GREEN "\033[32m" ///< ANSI code for setting a GREEN foreground.
|
||||
#define FG_YELLOW "\033[33m" ///< ANSI code for setting a YELLOW foreground.
|
||||
#define FG_BLUE "\033[34m" ///< ANSI code for setting a BLUE foreground.
|
||||
#define FG_MAGENTA "\033[35m" ///< ANSI code for setting a MAGENTA foreground.
|
||||
#define FG_CYAN "\033[36m" ///< ANSI code for setting a CYAN foreground.
|
||||
#define FG_WHITE "\033[37m" ///< ANSI code for setting a WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BOLD "\033[1;30m" ///< ANSI code for setting a BLACK foreground.
|
||||
#define FG_RED_BOLD "\033[1;31m" ///< ANSI code for setting a RED foreground.
|
||||
#define FG_GREEN_BOLD "\033[1;32m" ///< ANSI code for setting a GREEN foreground.
|
||||
#define FG_YELLOW_BOLD "\033[1;33m" ///< ANSI code for setting a YELLOW foreground.
|
||||
#define FG_BLUE_BOLD "\033[1;34m" ///< ANSI code for setting a BLUE foreground.
|
||||
#define FG_MAGENTA_BOLD "\033[1;35m" ///< ANSI code for setting a MAGENTA foreground.
|
||||
#define FG_CYAN_BOLD "\033[1;36m" ///< ANSI code for setting a CYAN foreground.
|
||||
#define FG_WHITE_BOLD "\033[1;37m" ///< ANSI code for setting a WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BRIGHT "\033[90m" ///< ANSI code for setting a BRIGHT_BLACK foreground.
|
||||
#define FG_RED_BRIGHT "\033[91m" ///< ANSI code for setting a BRIGHT_RED foreground.
|
||||
#define FG_GREEN_BRIGHT "\033[92m" ///< ANSI code for setting a BRIGHT_GREEN foreground.
|
||||
#define FG_YELLOW_BRIGHT "\033[93m" ///< ANSI code for setting a BRIGHT_YELLOW foreground.
|
||||
#define FG_BLUE_BRIGHT "\033[94m" ///< ANSI code for setting a BRIGHT_BLUE foreground.
|
||||
#define FG_MAGENTA_BRIGHT "\033[95m" ///< ANSI code for setting a BRIGHT_MAGENTA foreground.
|
||||
#define FG_CYAN_BRIGHT "\033[96m" ///< ANSI code for setting a BRIGHT_CYAN foreground.
|
||||
#define FG_WHITE_BRIGHT "\033[97m" ///< ANSI code for setting a BRIGHT_WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BRIGHT_BOLD "\033[1;90m" ///< ANSI code for setting a BRIGHT_BLACK foreground.
|
||||
#define FG_RED_BRIGHT_BOLD "\033[1;91m" ///< ANSI code for setting a BRIGHT_RED foreground.
|
||||
#define FG_GREEN_BRIGHT_BOLD "\033[1;92m" ///< ANSI code for setting a BRIGHT_GREEN foreground.
|
||||
#define FG_YELLOW_BRIGHT_BOLD "\033[1;93m" ///< ANSI code for setting a BRIGHT_YELLOW foreground.
|
||||
#define FG_BLUE_BRIGHT_BOLD "\033[1;94m" ///< ANSI code for setting a BRIGHT_BLUE foreground.
|
||||
#define FG_MAGENTA_BRIGHT_BOLD "\033[1;95m" ///< ANSI code for setting a BRIGHT_MAGENTA foreground.
|
||||
#define FG_CYAN_BRIGHT_BOLD "\033[1;96m" ///< ANSI code for setting a BRIGHT_CYAN foreground.
|
||||
#define FG_WHITE_BRIGHT_BOLD "\033[1;97m" ///< ANSI code for setting a BRIGHT_WHITE foreground.
|
||||
|
||||
#define BG_BLACK "\033[40m" ///< ANSI code for setting a BLACK background.
|
||||
#define BG_RED "\033[41m" ///< ANSI code for setting a RED background.
|
||||
#define BG_GREEN "\033[42m" ///< ANSI code for setting a GREEN background.
|
||||
#define BG_YELLOW "\033[43m" ///< ANSI code for setting a YELLOW background.
|
||||
#define BG_BLUE "\033[44m" ///< ANSI code for setting a BLUE background.
|
||||
#define BG_MAGENTA "\033[45m" ///< ANSI code for setting a MAGENTA background.
|
||||
#define BG_CYAN "\033[46m" ///< ANSI code for setting a CYAN background.
|
||||
#define BG_WHITE "\033[47m" ///< ANSI code for setting a WHITE background.
|
||||
|
||||
#define BG_BRIGHT_BLACK "\033[100m" ///< ANSI code for setting a BRIGHT_BLACK background.
|
||||
#define BG_BRIGHT_RED "\033[101m" ///< ANSI code for setting a BRIGHT_RED background.
|
||||
#define BG_BRIGHT_GREEN "\033[102m" ///< ANSI code for setting a BRIGHT_GREEN background.
|
||||
#define BG_BRIGHT_YELLOW "\033[103m" ///< ANSI code for setting a BRIGHT_YELLOW background.
|
||||
#define BG_BRIGHT_BLUE "\033[104m" ///< ANSI code for setting a BRIGHT_BLUE background.
|
||||
#define BG_BRIGHT_MAGENTA "\033[105m" ///< ANSI code for setting a BRIGHT_MAGENTA background.
|
||||
#define BG_BRIGHT_CYAN "\033[106m" ///< ANSI code for setting a BRIGHT_CYAN background.
|
||||
#define BG_BRIGHT_WHITE "\033[107m" ///< ANSI code for setting a BRIGHT_WHITE background.
|
||||
@@ -0,0 +1,127 @@
|
||||
/// @file debug.h
|
||||
/// @brief Debugging primitives.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/kernel_levels.h"
|
||||
|
||||
#ifndef __DEBUG_LEVEL__
|
||||
/// Defines the debug level, by default we set it to notice.
|
||||
#define __DEBUG_LEVEL__ LOGLEVEL_NOTICE
|
||||
#endif
|
||||
|
||||
#ifndef __DEBUG_HEADER__
|
||||
/// Header for identifying outputs coming from a mechanism.
|
||||
#define __DEBUG_HEADER__ 0
|
||||
#endif
|
||||
|
||||
/// @brief Extract the filename from the full path provided by __FILE__.
|
||||
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
/// @brief Sets the loglevel.
|
||||
/// @param level The new loglevel.
|
||||
void set_log_level(int level);
|
||||
|
||||
/// @brief Returns the current loglevel.
|
||||
/// @return The current loglevel
|
||||
int get_log_level(void);
|
||||
|
||||
/// @brief Prints the given character to debug output.
|
||||
/// @param c The character to print.
|
||||
void dbg_putchar(char c);
|
||||
|
||||
/// @brief Prints the given string to debug output.
|
||||
/// @param s The string to print.
|
||||
void dbg_puts(const char *s);
|
||||
|
||||
/// @brief Prints the given string to the debug output.
|
||||
/// @param file the name of the file.
|
||||
/// @param fun the name of the function.
|
||||
/// @param line the line inside the file.
|
||||
/// @param header the header to print.
|
||||
/// @param log_level the log level.
|
||||
/// @param format the format to used, see printf.
|
||||
/// @param ... the list of arguments.
|
||||
void dbg_printf(const char *file, const char *fun, int line, char *header, short log_level, const char *format, ...);
|
||||
|
||||
/// @brief Transforms the given amount of bytes to a readable string.
|
||||
/// @param bytes The bytes to turn to string.
|
||||
/// @return String representing the bytes in human readable form.
|
||||
const char *to_human_size(unsigned long bytes);
|
||||
|
||||
/// @brief Transforms the given value to a binary string.
|
||||
/// @param value to print.
|
||||
/// @param length of the binary output.
|
||||
/// @return String representing the binary value.
|
||||
const char *dec_to_binary(unsigned long value, unsigned length);
|
||||
|
||||
/// Prints a default message, which is always shown.
|
||||
#define pr_default(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_DEFAULT, __VA_ARGS__)
|
||||
|
||||
/// Prints an emergency message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_EMERG
|
||||
#define pr_emerg(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_EMERG, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_emerg(...)
|
||||
#endif
|
||||
|
||||
/// Prints an alert message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_ALERT
|
||||
#define pr_alert(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_ALERT, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_alert(...)
|
||||
#endif
|
||||
|
||||
/// Prints a critical message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_CRIT
|
||||
#define pr_crit(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_CRIT, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_crit(...)
|
||||
#endif
|
||||
|
||||
/// Prints an error message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_ERR
|
||||
#define pr_err(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_ERR, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_err(...)
|
||||
#endif
|
||||
|
||||
/// Prints a warning message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_WARNING
|
||||
#define pr_warning(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_WARNING, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_warning(...)
|
||||
#endif
|
||||
|
||||
/// Prints a notice message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_NOTICE
|
||||
#define pr_notice(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_NOTICE, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_notice(...)
|
||||
#endif
|
||||
|
||||
/// Prints a info message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_INFO
|
||||
#define pr_info(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_INFO, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_info(...)
|
||||
#endif
|
||||
|
||||
/// Prints a debug message.
|
||||
#if __DEBUG_LEVEL__ >= LOGLEVEL_DEBUG
|
||||
#define pr_debug(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__, LOGLEVEL_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
#define pr_debug(...)
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
struct pt_regs;
|
||||
|
||||
/// @brief Prints the registers on debug output.
|
||||
/// @param frame Pointer to the register.
|
||||
void dbg_print_regs(struct pt_regs *frame);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
/// MentOS, The Mentoring Operating system project
|
||||
/// @file mm_io.h
|
||||
/// @brief Memory Mapped IO functions.
|
||||
/// @copyright (c) 2019 This file is distributed under the MIT License.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
@@ -9,19 +8,31 @@
|
||||
#include "stdint.h"
|
||||
|
||||
/// @brief Reads a 8-bit value from the given address.
|
||||
/// @param addr the address we want to read from.
|
||||
/// @return the value we read.
|
||||
uint8_t in_memb(uint32_t addr);
|
||||
|
||||
/// @brief Reads a 16-bit value from the given address.
|
||||
/// @param addr the address we want to read from.
|
||||
/// @return the value we read.
|
||||
uint16_t in_mems(uint32_t addr);
|
||||
|
||||
/// @brief Reads a 32-bit value from the given address.
|
||||
/// @param addr the address we want to read from.
|
||||
/// @return the value we read.
|
||||
uint32_t in_meml(uint32_t addr);
|
||||
|
||||
/// @brief Writes a 8-bit value at the given address.
|
||||
/// @param addr the address we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
void out_memb(uint32_t addr, uint8_t value);
|
||||
|
||||
/// @brief Writes a 16-bit value at the given address.
|
||||
/// @param addr the address we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
void out_mems(uint32_t addr, uint16_t value);
|
||||
|
||||
/// @brief Writes a 32-bit value at the given address.
|
||||
/// @param addr the address we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
void out_meml(uint32_t addr, uint32_t value);
|
||||
@@ -0,0 +1,150 @@
|
||||
/// @file port_io.h
|
||||
/// @brief Byte I/O on ports prototypes.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Reads a 8-bit value from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @return the value we read.
|
||||
static inline unsigned char inportb(unsigned short port)
|
||||
{
|
||||
unsigned char result;
|
||||
__asm__ __volatile__("inb %%dx, %%al"
|
||||
: "=a"(result)
|
||||
: "dN"(port)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Reads a 16-bit value from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @return the value we read.
|
||||
static inline unsigned short inports(unsigned short port)
|
||||
{
|
||||
unsigned short result;
|
||||
__asm__ __volatile__("inw %1, %0"
|
||||
: "=a"(result)
|
||||
: "dN"(port)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Reads a 32-bit value from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @return the value we read.
|
||||
static inline unsigned int inportl(unsigned short port)
|
||||
{
|
||||
unsigned int result;
|
||||
__asm__ __volatile__("inl %%dx, %%eax"
|
||||
: "=a"(result)
|
||||
: "dN"(port)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Writes a 8-bit value at the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
static inline void outportb(unsigned short port, unsigned char value)
|
||||
{
|
||||
__asm__ __volatile__("outb %%al, %%dx"
|
||||
:
|
||||
: "a"(value), "dN"(port)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/// @brief Writes a 16-bit value at the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
static inline void outports(unsigned short port, unsigned short value)
|
||||
{
|
||||
__asm__ __volatile__("outw %1, %0"
|
||||
:
|
||||
: "dN"(port), "a"(value)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/// @brief Writes a 32-bit value at the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param value the value we want to write.
|
||||
static inline void outportl(unsigned short port, unsigned int value)
|
||||
{
|
||||
__asm__ __volatile__("outl %%eax, %%dx"
|
||||
:
|
||||
: "dN"(port), "a"(value)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/// @brief Reads multiple 8-bit values from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @param addr the location where we store the values we read.
|
||||
/// @param count the number of values we want to read.
|
||||
static inline void inportsb(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; insb "
|
||||
: "=D"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
|
||||
/// @brief Reads multiple 16-bit values from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @param addr the location where we store the values we read.
|
||||
/// @param count the number of values we want to read.
|
||||
static inline void inportsw(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; insw "
|
||||
: "=D"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
|
||||
/// @brief Reads multiple 32-bit values from the given port.
|
||||
/// @param port the port we want to read from.
|
||||
/// @param addr the location where we store the values we read.
|
||||
/// @param count the number of values we want to read.
|
||||
static inline void inportsl(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; insl "
|
||||
: "=D"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
|
||||
/// @brief Writes multiple 8-bit values to the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param addr the location where we get the values we need to write.
|
||||
/// @param count the number of values we want to write.
|
||||
static inline void outportsb(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; outsb "
|
||||
: "=S"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
|
||||
/// @brief Writes multiple 16-bit values to the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param addr the location where we get the values we need to write.
|
||||
/// @param count the number of values we want to write.
|
||||
static inline void outportsw(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; outsw "
|
||||
: "=S"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
|
||||
/// @brief Writes multiple 32-bit values to the given port.
|
||||
/// @param port the port we want to write to.
|
||||
/// @param addr the location where we get the values we need to write.
|
||||
/// @param count the number of values we want to write.
|
||||
static inline void outportsl(unsigned short port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cld ; rep ; outsl "
|
||||
: "=S"(addr), "=c"(count)
|
||||
: "d"(port), "0"(addr), "1"(count));
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/// @file libgen.h
|
||||
/// @brief String routines.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief Extracts the parent directory of the given path and saves it inside
|
||||
/// the given buffer, e.g., from "/home/user/test.txt" it extracts "/home/user".
|
||||
/// If the path does not contain a '/', it will return ".".
|
||||
/// @param path the path we are parsing.
|
||||
/// @param buffer the buffer where we save the directory name.
|
||||
/// @param buflen the length of the buffer.
|
||||
/// @return 1 if succesfull, or 0 if the buffer cannot contain the path.
|
||||
int dirname(const char *path, char *buffer, size_t buflen);
|
||||
|
||||
/// @brief Extract the component after the final '/'.
|
||||
/// @param path the path from which we extract the final component.
|
||||
/// @return a pointer after the final '/', or path itself it none was found.
|
||||
const char *basename(const char *path);
|
||||
|
||||
/// @brief Return the canonicalized absolute pathname.
|
||||
/// @param path the path we are canonicalizing.
|
||||
/// @param buffer where we will store the canonicalized path.
|
||||
/// @param buflen the size of the buffer.
|
||||
/// @return If there is no error, realpath() returns a pointer to the buffer.
|
||||
/// Otherwise, it returns NULL, the contents of the array buffer are undefined,
|
||||
/// and errno is set to indicate the error.
|
||||
char *realpath(const char *path, char *buffer, size_t buflen);
|
||||
@@ -0,0 +1,60 @@
|
||||
/// @file limits.h
|
||||
/// @brief OS numeric limits.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Number of bits in a `char'.
|
||||
#define CHAR_BIT 8
|
||||
|
||||
/// Minimum value a `signed char' can hold.
|
||||
#define SCHAR_MIN -128
|
||||
|
||||
/// Maximum value a `signed char' can hold.
|
||||
#define SCHAR_MAX +127
|
||||
|
||||
/// Minimum value a `signed char' can hold.
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
|
||||
/// Maximum value a `signed char' can hold.
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
|
||||
/// Maximum value a `char' can hold.
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
/// Minimum value a `signed short int' can hold.
|
||||
#define SHRT_MIN (-32768)
|
||||
|
||||
/// Maximum value a `signed short int' can hold.
|
||||
#define SHRT_MAX (+32767)
|
||||
|
||||
/// Maximum value a `unsigned short int' can hold.
|
||||
#define USHRT_MAX 65535
|
||||
|
||||
/// Minimum value a `signed int' can hold.
|
||||
#define INT_MIN (-2147483648)
|
||||
|
||||
/// Maximum values a `signed int' can hold.
|
||||
#define INT_MAX (+2147483647)
|
||||
|
||||
/// Maximum value an `unsigned int' can hold.
|
||||
#define UINT_MAX (+2147483647)
|
||||
|
||||
/// Maximum value a `signed long int' can hold.
|
||||
#define LONG_MIN (-2147483648L)
|
||||
|
||||
/// Minimum value a `signed long int' can hold.
|
||||
#define LONG_MAX (+2147483647L)
|
||||
|
||||
/// Maximum number of characters in a file name.
|
||||
#define NAME_MAX 255
|
||||
|
||||
/// Maximum number of characters in a path name.
|
||||
#define PATH_MAX 4096
|
||||
|
||||
/// Maximum length of arguments provided to exec function.
|
||||
#define ARG_MAX 256
|
||||
|
||||
/// Maximum pid number.
|
||||
#define PID_MAX_LIMIT 32768
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
/// @file math.h
|
||||
/// @brief Mathematical constants and functions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief The absolute value.
|
||||
#define abs(a) (((a) < 0) ? -(a) : (a))
|
||||
|
||||
/// @brief The max of the two values.
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
/// @brief The min of the two values.
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
/// @brief The sign the the passed value.
|
||||
#define sign(x) ((x < 0) ? -1 : ((x > 0) ? 1 : 0))
|
||||
|
||||
/// @brief Returns a rounded up, away from zero, to the nearest multiple of b.
|
||||
#define round_up(number, base) (((number) + (base)-1) & ~((base)-1))
|
||||
|
||||
/// @brief e
|
||||
#define M_E 2.7182818284590452354
|
||||
|
||||
/// @brief log_2 e
|
||||
#define M_LOG2E 1.4426950408889634074
|
||||
|
||||
/// @brief log_10 e
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
|
||||
/// @brief log_e 2
|
||||
#define M_LN2 0.69314718055994530942
|
||||
|
||||
/// @brief log_e 10
|
||||
#define M_LN10 2.30258509299404568402
|
||||
|
||||
/// @brief pi
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
/// @brief pi / 2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
|
||||
/// @brief pi / 4
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
|
||||
/// @brief 1 / pi
|
||||
#define M_1_PI 0.31830988618379067154
|
||||
|
||||
/// @brief 2 / pi
|
||||
#define M_2_PI 0.63661977236758134308
|
||||
|
||||
/// @brief 2 / sqrt(pi)
|
||||
#define M_2_SQRTPI 1.12837916709551257390
|
||||
|
||||
/// @brief sqrt(2)
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
|
||||
/// @brief 1 / sqrt(2)
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
|
||||
/// @brief Returns the integral value that is nearest to x, with
|
||||
/// halfway cases rounded away from zero.
|
||||
/// @param x Value to round.
|
||||
/// @result The value of x rounded to the nearest integral
|
||||
/// (as a floating-point value).
|
||||
double round(double x);
|
||||
|
||||
/// @brief Rounds x upward, returning the smallest integral value
|
||||
/// that is not less than x.
|
||||
/// @param x Value to round up.
|
||||
/// @return The smallest integral value that is not less than x
|
||||
/// (as a floating-point value).
|
||||
double ceil(double x);
|
||||
|
||||
/// @brief Rounds x downward, returning the largest integral value
|
||||
/// that is not greater than x.
|
||||
/// @param x Value to round down.
|
||||
/// @return The value of x rounded downward (as a floating-point value).
|
||||
double floor(double x);
|
||||
|
||||
/// @brief Returns base raised to the power exponent:
|
||||
/// @param base Base value.
|
||||
/// @param exponent Exponent value.
|
||||
/// @result The result of raising base to the power exponent.
|
||||
/// @details
|
||||
/// If the base is finite negative and the exponent is finite but not an
|
||||
/// integer value, it causes a domain error.
|
||||
/// If both base and exponent are zero, it may also cause a domain error
|
||||
/// on certain implementations.
|
||||
/// If base is zero and exponent is negative, it may cause a domain error
|
||||
/// or a pole error (or none, depending on the library implementation).
|
||||
/// The function may also cause a range error if the result is too great
|
||||
/// or too small to be represented by a value of the return type.
|
||||
double pow(double base, double exponent);
|
||||
|
||||
/// @brief Returns the base-e exponential function of x, which is e raised
|
||||
/// to the power x: e^x.
|
||||
/// @param x Value of the exponent.
|
||||
/// @return Exponential value of x.
|
||||
/// @details
|
||||
/// If the magnitude of the result is too large to be represented by a value
|
||||
/// of the return type, the function returns HUGE_VAL (or HUGE_VALF or
|
||||
/// HUGE_VALL) with the proper sign, and an overflow range error occurs and
|
||||
/// the global variable errno is set to ERANGE.
|
||||
double exp(double x);
|
||||
|
||||
/// @brief Returns the absolute value of x: |x|.
|
||||
/// @param x Value whose absolute value is returned.
|
||||
/// @result The absolute value of x.
|
||||
double fabs(double x);
|
||||
|
||||
/// @brief Returns the absolute value of x: |x|.
|
||||
/// @param x Value whose absolute value is returned.
|
||||
/// @result The absolute value of x.
|
||||
float fabsf(float x);
|
||||
|
||||
/// @brief Returns the square root of x.
|
||||
/// @param x Value whose square root is computed.
|
||||
/// @return Square root of x. If x is negative, the global variable errno
|
||||
/// is set to EDOM.
|
||||
double sqrt(double x);
|
||||
|
||||
/// @brief Returns the square root of x.
|
||||
/// @param x Value whose square root is computed.
|
||||
/// @return Square root of x. If x is negative, the global variable errno
|
||||
/// is set to EDOM.
|
||||
float sqrtf(float x);
|
||||
|
||||
/// @brief Checks if the input value is Infinite (INF).
|
||||
/// @param x The value to check.
|
||||
/// @return 1 if INF, 0 otherwise.
|
||||
int isinf(double x);
|
||||
|
||||
/// @brief Checks if the input value is Not A Number (NAN).
|
||||
/// @param x The value to check.
|
||||
/// @return 1 if NAN, 0 otherwise.
|
||||
int isnan(double x);
|
||||
|
||||
/// @brief Logarithm function in base 10.
|
||||
/// @param x Topic of the logarithm function.
|
||||
/// @return Return the result.
|
||||
double log10(double x);
|
||||
|
||||
/// @brief Natural logarithm function.
|
||||
/// @param x Topic of the logarithm function.
|
||||
/// @return Return the result.
|
||||
double ln(double x);
|
||||
|
||||
/// @brief Logarithm function in base x.
|
||||
/// @param x Base of the logarithm.
|
||||
/// @param y Topic of the logarithm function.
|
||||
/// @return Return the result.
|
||||
double logx(double x, double y);
|
||||
|
||||
/// @brief Breaks x into an integral and a fractional part, both parts have the same sign as x.
|
||||
/// @param x The value we want to break.
|
||||
/// @param intpart Where we store the integer part.
|
||||
/// @return the fractional part.
|
||||
double modf(double x, double *intpart);
|
||||
@@ -0,0 +1,55 @@
|
||||
/// @file pwd.h
|
||||
/// @brief Contains the structure and functions for managing passwords.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief Stores user account information.
|
||||
typedef struct passwd_t {
|
||||
char *pw_name; ///< User's login name.
|
||||
char *pw_passwd; ///< Encrypted password (not currently).
|
||||
uid_t pw_uid; ///< User ID.
|
||||
gid_t pw_gid; ///< Group ID.
|
||||
char *pw_gecos; ///< User's full name.
|
||||
char *pw_dir; ///< User's login directory.
|
||||
char *pw_shell; ///< User's login shell.
|
||||
} passwd_t;
|
||||
|
||||
/// @brief Provides access to the password database entry for `name`.
|
||||
/// @param name The name to search inside the database.
|
||||
/// @return A pointer to the structure containing the database entry.
|
||||
passwd_t *getpwnam(const char *name);
|
||||
|
||||
/// @brief Provides access to the password database entry for `uid`.
|
||||
/// @param uid The uid to search inside the database.
|
||||
/// @return A pointer to the structure containing the database entry.
|
||||
passwd_t *getpwuid(uid_t uid);
|
||||
|
||||
/// @brief Provides the same information as getpwnam but it stores the
|
||||
/// results inside pwd, and the string information are store store
|
||||
/// inside `buf`.
|
||||
/// @param name The name to search inside the database.
|
||||
/// @param pwd The structure containing pointers to the entry fields.
|
||||
/// @param buf The buffer where the strings should be stored.
|
||||
/// @param buflen The lenght of the buffer.
|
||||
/// @param result A pointer to the result or NULL is stored here.
|
||||
/// @return If the entry was found returns zero and set *result to pwd,
|
||||
/// if the entry was not found returns zero and set *result to NULL,
|
||||
/// on failure returns a number and sets and set *result to NULL.
|
||||
int getpwnam_r(const char *name, passwd_t *pwd, char *buf, size_t buflen, passwd_t **result);
|
||||
|
||||
/// @brief Provides the same information as getpwuid but it stores the
|
||||
/// results inside pwd, and the string information are store store
|
||||
/// inside `buf`.
|
||||
/// @param uid The uid to search inside the database.
|
||||
/// @param pwd The structure containing pointers to the entry fields.
|
||||
/// @param buf The buffer where the strings should be stored.
|
||||
/// @param buflen The lenght of the buffer.
|
||||
/// @param result A pointer to the result or NULL is stored here.
|
||||
/// @return If the entry was found returns zero and set *result to pwd,
|
||||
/// if the entry was not found returns zero and set *result to NULL,
|
||||
/// on failure returns a number and sets and set *result to NULL.
|
||||
int getpwuid_r(uid_t uid, passwd_t *pwd, char *buf, size_t buflen, passwd_t **result);
|
||||
@@ -0,0 +1,14 @@
|
||||
/// @file readline.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief Reads a line from the file.
|
||||
/// @param fd the file descriptor.
|
||||
/// @param buffer the buffer where we place the line.
|
||||
/// @param buflen the length of the buffer.
|
||||
/// @param readlen the amount we read, if negative, we did not encounter a newline.
|
||||
/// @return 0 if we are done reading, 1 if we encountered a newline, -1 if otherwise.
|
||||
int readline(int fd, char *buffer, size_t buflen, ssize_t *read_len);
|
||||
@@ -0,0 +1,127 @@
|
||||
/// @file ring_buffer.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Declares a fixed-size ring-buffer.
|
||||
#define DECLARE_FIXED_SIZE_RING_BUFFER(type, name, length, init) \
|
||||
typedef struct fs_rb_##name##_t { \
|
||||
unsigned size, read, write; \
|
||||
type buffer[length]; \
|
||||
} fs_rb_##name##_t; \
|
||||
static inline void fs_rb_##name##_init(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
rb->size = length; \
|
||||
rb->read = rb->write = 0; \
|
||||
char *dst = (char *)rb->buffer; \
|
||||
long num = sizeof(type) * length; \
|
||||
while (num--) *dst++ = (char)(init & 0xFF); \
|
||||
} \
|
||||
static inline unsigned fs_rb_##name##_step(fs_rb_##name##_t *rb, unsigned index) \
|
||||
{ \
|
||||
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||
} \
|
||||
static inline void fs_rb_##name##_push_front(fs_rb_##name##_t *rb, type item) \
|
||||
{ \
|
||||
if (fs_rb_##name##_step(rb, rb->write) == rb->read) \
|
||||
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||
rb->buffer[rb->write] = item; \
|
||||
rb->write = fs_rb_##name##_step(rb, rb->write); \
|
||||
} \
|
||||
static inline type fs_rb_##name##_empty(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
return rb->write == rb->read; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_pop_back(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
type item = init; \
|
||||
if (!fs_rb_##name##_empty(rb)) { \
|
||||
item = rb->buffer[rb->read]; \
|
||||
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||
} \
|
||||
return item; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_pop_front(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
if (fs_rb_##name##_empty(rb)) \
|
||||
return init; \
|
||||
rb->write = (rb->write > 0) ? rb->write - 1 : rb->size - 1; \
|
||||
return rb->buffer[rb->write]; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_get(fs_rb_##name##_t *rb, unsigned index) \
|
||||
{ \
|
||||
if (index < rb->size) \
|
||||
return rb->buffer[index]; \
|
||||
return init; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_back(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
if (fs_rb_##name##_empty(rb)) \
|
||||
return init; \
|
||||
return rb->buffer[rb->read]; \
|
||||
} \
|
||||
static inline type fs_rb_##name##_front(fs_rb_##name##_t *rb) \
|
||||
{ \
|
||||
if (fs_rb_##name##_empty(rb)) \
|
||||
return init; \
|
||||
return rb->buffer[(rb->write > 0) ? rb->write - 1 : rb->size - 1]; \
|
||||
}
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/// Function for allocating memory for the ring buffer.
|
||||
#define RING_BUFFER_ALLOC kmalloc
|
||||
/// Function for freeing the memory for the ring buffer.
|
||||
#define RING_BUFFER_FREE kfree
|
||||
#else
|
||||
/// Function for allocating memory for the ring buffer.
|
||||
#define RING_BUFFER_ALLOC malloc
|
||||
/// Function for freeing the memory for the ring buffer.
|
||||
#define RING_BUFFER_FREE free
|
||||
#endif
|
||||
|
||||
/// @brief Declares a dynamic-size ring-buffer.
|
||||
#define DECLARE_RING_BUFFER(type, name, init) \
|
||||
typedef struct rb_##name##_t { \
|
||||
const unsigned size; \
|
||||
unsigned read, write; \
|
||||
type *buffer; \
|
||||
} rb_##name##_t; \
|
||||
static inline rb_##name##_t alloc_rb_##name(unsigned len) \
|
||||
{ \
|
||||
rb_##name##_t rb = { len, 0U, 0U, len > 0 ? RING_BUFFER_ALLOC(sizeof(type) * len) : NULL }; \
|
||||
memset(rb.buffer, init, sizeof(type) * len); \
|
||||
return rb; \
|
||||
} \
|
||||
static inline void free_rb_##name(rb_##name##_t *rb) \
|
||||
{ \
|
||||
RING_BUFFER_FREE(rb->buffer); \
|
||||
} \
|
||||
static inline unsigned step_rb_##name(rb_##name##_t *rb, unsigned index) \
|
||||
{ \
|
||||
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||
} \
|
||||
static inline void push_rb_##name(rb_##name##_t *rb, type item) \
|
||||
{ \
|
||||
if (step_rb_##name(rb, rb->write) == rb->read) \
|
||||
rb->read = step_rb_##name(rb, rb->read); \
|
||||
rb->buffer[rb->write] = item; \
|
||||
rb->write = step_rb_##name(rb, rb->write); \
|
||||
} \
|
||||
static inline void pop_rb_##name(rb_##name##_t *rb, type *item) \
|
||||
{ \
|
||||
*item = init; \
|
||||
if (rb->write != rb->read) { \
|
||||
*item = rb->buffer[rb->read]; \
|
||||
rb->read = step_rb_##name(rb, rb->read); \
|
||||
} \
|
||||
} \
|
||||
static inline void get_rb_##name(rb_##name##_t *rb, unsigned index, type *item) \
|
||||
{ \
|
||||
if (index < rb->size) \
|
||||
*item = rb->buffer[index]; \
|
||||
}
|
||||
|
||||
#undef RING_BUFFER_ALLOC
|
||||
#undef RING_BUFFER_FREE
|
||||
@@ -0,0 +1,43 @@
|
||||
/// @file sched.h
|
||||
/// @brief Structures and functions for managing the scheduler.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "time.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
/// @brief Structure that describes scheduling parameters.
|
||||
typedef struct sched_param_t {
|
||||
/// Static execution priority.
|
||||
int sched_priority;
|
||||
/// Expected period of the task
|
||||
time_t period;
|
||||
/// Absolute deadline
|
||||
time_t deadline;
|
||||
/// Absolute time of arrival of the task
|
||||
time_t arrivaltime;
|
||||
/// Is task periodic?
|
||||
bool_t is_periodic;
|
||||
} sched_param_t;
|
||||
|
||||
/// @brief Sets scheduling parameters.
|
||||
/// @param pid pid of the process we want to change the parameters. If zero,
|
||||
/// then the parameters of the calling process are set.
|
||||
/// @param param The interpretation of the argument param depends on the
|
||||
/// scheduling policy of the thread identified by pid.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int sched_setparam(pid_t pid, const sched_param_t *param);
|
||||
|
||||
/// @brief Gets scheduling parameters.
|
||||
/// @param pid pid of the process we want to retrieve the parameters. If zero,
|
||||
/// then the parameters of the calling process are returned.
|
||||
/// @param param The interpretation of the argument param depends on the
|
||||
/// scheduling policy of the thread identified by pid.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int sched_getparam(pid_t pid, sched_param_t *param);
|
||||
|
||||
/// @brief Placed at the end of an infinite while loop, stops the process until,
|
||||
/// its next period starts. The calling process must be a periodic one.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int waitperiod(void);
|
||||
@@ -0,0 +1,272 @@
|
||||
/// @file signal.h
|
||||
/// @brief Signals definition.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/types.h"
|
||||
|
||||
/// @brief List of signals.
|
||||
typedef enum {
|
||||
SIGHUP = 1, ///< Hang up detected on controlling terminal or death of controlling process.
|
||||
SIGINT = 2, ///< Issued if the user sends an interrupt signal (Ctrl + C).
|
||||
SIGQUIT = 3, ///< Issued if the user sends a quit signal (Ctrl + D).
|
||||
SIGILL = 4, ///< Illegal Instruction.
|
||||
SIGTRAP = 5, ///< Trace/breakpoint trap.
|
||||
SIGABRT = 6, ///< Abort signal from abort().
|
||||
SIGEMT = 7, ///< Emulator trap.
|
||||
SIGFPE = 8, ///< Floating-point arithmetic exception.
|
||||
SIGKILL = 9, ///< If a process gets this signal it must quit immediately and will not perform any clean-up operations.
|
||||
SIGBUS = 10, ///< Bus error (bad memory access).
|
||||
SIGSEGV = 11, ///< Invalid memory reference.
|
||||
SIGSYS = 12, ///< Bad system call (SVr4).
|
||||
SIGPIPE = 13, ///< Broken pipe: write to pipe with no readers.
|
||||
SIGALRM = 14, ///< Alarm clock signal (used for timers).
|
||||
SIGTERM = 15, ///< Software termination signal (sent by kill by default).
|
||||
SIGUSR1 = 16, ///< User-defined signal 1.
|
||||
SIGUSR2 = 17, ///< User-defined signal 2.
|
||||
SIGCHLD = 18, ///< Child stopped or terminated.
|
||||
SIGPWR = 19, ///< Power failure.
|
||||
SIGWINCH = 20, ///< Window resize signal.
|
||||
SIGURG = 21, ///< Urgent condition on socket.
|
||||
SIGPOLL = 22, ///< Pollable event.
|
||||
SIGSTOP = 23, ///< Stop process.
|
||||
SIGTSTP = 24, ///< Stop typed at terminal.
|
||||
SIGCONT = 25, ///< Continue if stopped.
|
||||
SIGTTIN = 26, ///< Terminal input for background process.
|
||||
SIGTTOU = 27, ///< Terminal output for background process.
|
||||
SIGVTALRM = 28, ///< Virtual alarm clock.
|
||||
SIGPROF = 29, ///< Profiling timer expired.
|
||||
SIGXCPU = 30, ///< CPU time limit exceeded.
|
||||
SIGXFSZ = 31, ///< File size limit exceeded.
|
||||
NSIG
|
||||
} signal_type_t;
|
||||
|
||||
/// @brief Codes that indentify the sender of a signal.
|
||||
typedef enum {
|
||||
SI_NOINFO, ///< Unable to determine complete signal information.
|
||||
|
||||
// Signal : -
|
||||
// Enabled fields : si_pid, si_uid
|
||||
SI_USER, ///< Signal sent by kill(), pthread_kill(), raise(), abort() or alarm().
|
||||
|
||||
// Signal : -
|
||||
// Enabled fields : -
|
||||
SI_KERNEL, ///< Generic kernel function
|
||||
|
||||
// Signal : -
|
||||
// Enabled fields : si_pid, si_uid, si_value
|
||||
SI_QUEUE, ///< Signal was sent by sigqueue().
|
||||
SI_TIMER, ///< Signal was generated by expiration of a timer set by timer_settimer().
|
||||
SI_ASYNCIO, ///< Signal was generated by completion of an asynchronous I/O request.
|
||||
SI_MESGQ, ///< Signal was generated by arrival of a message on an empty message queue.
|
||||
|
||||
// Signal : SIGILL
|
||||
// Enabled fields : si_addr (address of failing instruction)
|
||||
ILL_ILLOPC, ///< Illegal opcode.
|
||||
ILL_ILLOPN, ///< Illegal operand.
|
||||
ILL_ILLADR, ///< Illegal addressing mode.
|
||||
ILL_ILLTRP, ///< Illegal trap.
|
||||
ILL_PRVOPC, ///< Privileged opcode.
|
||||
ILL_PRVREG, ///< Privileged register.
|
||||
ILL_COPROC, ///< Coprocessor error.
|
||||
ILL_BADSTK, ///< Internal stack error.
|
||||
|
||||
// Signal : SIGFPE
|
||||
// Enabled fields : si_addr (address of failing instruction)
|
||||
FPE_INTDIV, ///< Integer divide-by-zero.
|
||||
FPE_INTOVF, ///< Integer overflow.
|
||||
FPE_FLTDIV, ///< Floating point divide-by-zero.
|
||||
FPE_FLTOVF, ///< Floating point overflow.
|
||||
FPE_FLTUND, ///< Floating point underflow.
|
||||
FPE_FLTRES, ///< Floating point inexact result.
|
||||
FPE_FLTINV, ///< Invalid floating point operation.
|
||||
FPE_FLTSUB, ///< Subscript out of range.
|
||||
|
||||
// Signal : SIGSEGV
|
||||
// Enabled fields : si_addr (address of faulting memory reference)
|
||||
SEGV_MAPERR, ///< Address not mapped.
|
||||
SEGV_ACCERR, ///< Invalid permissions.
|
||||
|
||||
// Signal : SIGBUS
|
||||
// Enabled fields : si_addr (address of faulting memory reference)
|
||||
BUS_ADRALN, ///< Invalid address alignment.
|
||||
BUS_ADRERR, ///< Non-existent physical address.
|
||||
BUS_OBJERR, ///< Object-specific hardware error.
|
||||
|
||||
// Signal : SIGTRAP
|
||||
// Enabled fields : -
|
||||
TRAP_BRKPT, ///< Process breakpoint.
|
||||
TRAP_TRACE, ///< Process trace trap.
|
||||
|
||||
// Signal : SIGCHLD
|
||||
// Enabled fields : si_pid (child process ID)
|
||||
// si_uid (real user ID of process that sent the signal)
|
||||
// si_status (exit value or signal)
|
||||
CLD_EXITED, ///< Child has exited.
|
||||
CLD_KILLED, ///< Child has terminated abnormally and did not create a core file.
|
||||
CLD_DUMPED, ///< Child has terminated abnormally and created a core file.
|
||||
CLD_TRAPPED, ///< Traced child has trapped.
|
||||
CLD_STOPPED, ///< Child has stopped.
|
||||
CLD_CONTINUED, ///< Stopped child has continued.
|
||||
|
||||
// Signal : SIGIO/SIGPOLL
|
||||
// Enabled fields : si_band
|
||||
POLL_IN, ///< Data input available.
|
||||
POLL_OUT, ///< Output buffers available.
|
||||
POLL_MSG, ///< Input message available.
|
||||
POLL_ERR, ///< I/O error.
|
||||
POLL_PRI, ///< High priority input available.
|
||||
POLL_HUP, ///< Device disconnected.
|
||||
} signal_sender_code_t;
|
||||
|
||||
/// @brief Defines what to do with the provided signal mask.
|
||||
typedef enum {
|
||||
/// @brief The set of blocked signals is the union of the current set
|
||||
/// and the set argument.
|
||||
SIG_BLOCK,
|
||||
/// @brief The signals in set are removed from the current set of
|
||||
/// blocked signals. It is permissible to attempt to unblock
|
||||
/// a signal which is not blocked.
|
||||
SIG_UNBLOCK,
|
||||
/// @brief The set of blocked signals is set to the argument set.
|
||||
SIG_SETMASK
|
||||
} sigmask_how_t;
|
||||
|
||||
/// @defgroup SigactionFlags Flags associated with a sigaction.
|
||||
/// @{
|
||||
|
||||
#define SA_NOCLDSTOP 0x00000001U ///< Turn off SIGCHLD when children stop.
|
||||
#define SA_NOCLDWAIT 0x00000002U ///< Flag on SIGCHLD to inhibit zombies.
|
||||
#define SA_SIGINFO 0x00000004U ///< sa_sigaction specifies the signal-handling function for signum.
|
||||
#define SA_ONSTACK 0x08000000U ///< Indicates that a registered stack_t will be used.
|
||||
#define SA_RESTART 0x10000000U ///< Flag to get restarting signals (which were the default long ago)
|
||||
#define SA_NODEFER 0x40000000U ///< Prevents the current signal from being masked in the handler.
|
||||
#define SA_RESETHAND 0x80000000U ///< Clears the handler when the signal is delivered.
|
||||
|
||||
/// @}
|
||||
|
||||
/// Type of a signal handler.
|
||||
typedef void (*sighandler_t)(int);
|
||||
|
||||
#define SIG_DFL ((sighandler_t)0) ///< Default signal handling.
|
||||
#define SIG_IGN ((sighandler_t)1) ///< Ignore signal.
|
||||
#define SIG_ERR ((sighandler_t)-1) ///< Error return from signal.
|
||||
|
||||
/// @brief Structure used to mask and unmask signals.
|
||||
/// @details
|
||||
/// Each unsigned long consists of 32 bits, thus, the maximum number of signals
|
||||
/// that may be declared is 64.
|
||||
/// Signals are divided into two cathegories, identified by the two unsigned longs:
|
||||
/// [ 1, 31] corresponds to normal signals;
|
||||
/// [32, 64] corresponds to real-time signals.
|
||||
typedef struct sigset_t {
|
||||
/// Signals divided into two cathegories.
|
||||
unsigned long sig[2];
|
||||
} sigset_t;
|
||||
|
||||
/// @brief Holds the information on how to handle a specific signal.
|
||||
typedef struct sigaction_t {
|
||||
/// This field specifies the type of action to be performed; its value can be a pointer
|
||||
/// to the signal handler, SIG_DFL (that is, the value 0) to specify that the default
|
||||
/// action is performed, or SIG_IGN (that is, the value 1) to specify that the signal is
|
||||
/// ignored.
|
||||
sighandler_t sa_handler;
|
||||
/// This sigset_t variable specifies the signals to be masked when running the signal handler
|
||||
sigset_t sa_mask;
|
||||
/// This set of flags specifies how the signal must be handled;
|
||||
unsigned int sa_flags;
|
||||
} sigaction_t;
|
||||
|
||||
/// @brief Data passed with signal info.
|
||||
typedef union sigval {
|
||||
int sival_int; ///< Integer value.
|
||||
void *sival_ptr; ///< Pointer value.
|
||||
} sigval_t;
|
||||
|
||||
/// @brief Stores information about an occurrence of a specific signal.
|
||||
typedef struct siginfo_t {
|
||||
/// The signal number.
|
||||
int si_signo;
|
||||
/// A code identifying who raised the signal (see signal_sender_code_t).
|
||||
int si_code;
|
||||
/// Signal value.
|
||||
sigval_t si_value;
|
||||
/// The error code of the instruction that caused the signal to be raised, or 0 if there was no error.
|
||||
int si_errno;
|
||||
/// Process ID of sending process.
|
||||
pid_t si_pid;
|
||||
/// Real user ID of sending process.
|
||||
uid_t si_uid;
|
||||
/// Address at which fault occurred.
|
||||
void *si_addr;
|
||||
/// Exit value or signal for process termination.
|
||||
int si_status;
|
||||
/// Band event for SIGPOLL/SIGIO.
|
||||
int si_band;
|
||||
} siginfo_t;
|
||||
|
||||
/// @brief Send signal to a process.
|
||||
/// @param pid The pid of the process to which we send the signal.
|
||||
/// @param sig The type of signal to send.
|
||||
/// @return On success 0, on error -1 and errno is set appropriately.
|
||||
int kill(pid_t pid, int sig);
|
||||
|
||||
/// @brief Sets the disposition of the signal signum to handler.
|
||||
/// @param signum The signal number.
|
||||
/// @param handler The handler for the signal.
|
||||
/// @return The previous value of the signal handler, or SIG_ERR on error.
|
||||
sighandler_t signal(int signum, sighandler_t handler);
|
||||
|
||||
/// @brief Examine and change a signal action.
|
||||
/// @param signum Specifies the signal and can be any valid signal except SIGKILL and SIGSTOP.
|
||||
/// @param act If non-NULL, the new action for signal signum is installed from act.
|
||||
/// @param oldact If non-NULL, the previous action is saved in oldact.
|
||||
/// @return returns 0 on success; on error, -1 is returned, and errno is set to indicate the error.
|
||||
int sigaction(int signum, const sigaction_t *act, sigaction_t *oldact);
|
||||
|
||||
/// @brief Examine and change blocked signals.
|
||||
/// @param how Determines the behavior of the call.
|
||||
/// @param set The set of signals to manage by the function.
|
||||
/// @param oldset If non-NULL, the previous value of the signal mask is stored here.
|
||||
/// @return returns 0 on success, and -1 on error (errno is set to indicate the cause).
|
||||
/// @details
|
||||
/// If set is NULL, then the signal mask is unchanged (i.e., how is
|
||||
/// ignored), but the current value of the signal mask is
|
||||
/// nevertheless returned in oldset (if it is not NULL).
|
||||
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
|
||||
|
||||
/// @brief Returns the string describing the given signal.
|
||||
/// @param sig The signal to inquire.
|
||||
/// @return String representing the signal.
|
||||
const char *strsignal(int sig);
|
||||
|
||||
/// @brief Prepare an empty set.
|
||||
/// @param set The set to manipulate.
|
||||
/// @return 0 on success and -1 on error.
|
||||
int sigemptyset(sigset_t *set);
|
||||
|
||||
/// @brief Prepare a full set.
|
||||
/// @param set The set to manipulate.
|
||||
/// @return 0 on success and -1 on error.
|
||||
int sigfillset(sigset_t *set);
|
||||
|
||||
/// @brief Adds the given signal to the correct set.
|
||||
/// @param set The set to manipulate.
|
||||
/// @param signum The signalt to handle.
|
||||
/// @return 0 on success and -1 on error.
|
||||
int sigaddset(sigset_t *set, int signum);
|
||||
|
||||
/// @brief Removes the given signal to the correct set.
|
||||
/// @param set The set to manipulate.
|
||||
/// @param signum The signalt to handle.
|
||||
/// @return 0 on success and -1 on error.
|
||||
int sigdelset(sigset_t *set, int signum);
|
||||
|
||||
/// @brief Checks if the given signal is part of the set.
|
||||
/// @param set The set to manipulate.
|
||||
/// @param signum The signalt to handle.
|
||||
/// @return 1 if signum is a member of set,
|
||||
/// 0 if signum is not a member, and -1 on error.
|
||||
int sigismember(sigset_t *set, int signum);
|
||||
@@ -1,7 +1,6 @@
|
||||
/// MentOS, The Mentoring Operating system project
|
||||
/// @file stdarg.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2019 This file is distributed under the MIT License.
|
||||
/// @brief Contains the macros required to manage variable number of arguments.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
@@ -16,7 +15,7 @@ typedef char *va_list;
|
||||
|
||||
/// @brief Amount of space required in an argument list (ie. the stack) for an
|
||||
/// argument of type t.
|
||||
#define va_size(t) \
|
||||
#define va_size(t) \
|
||||
(((sizeof(t) + sizeof(va_item) - 1) / sizeof(va_item)) * sizeof(va_item))
|
||||
|
||||
/// @brief The start of a variadic list.
|
||||
@@ -0,0 +1,12 @@
|
||||
/// @file stdbool.h
|
||||
/// @brief Defines the boolean values.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Define boolean value.
|
||||
typedef enum bool_t {
|
||||
false, ///< [0] False.
|
||||
true ///< [1] True.
|
||||
} __attribute__((__packed__)) bool_t;
|
||||
@@ -0,0 +1,80 @@
|
||||
/// @file stddef.h
|
||||
/// @brief Define basic data types.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NULL
|
||||
/// @brief Define NULL.
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef EOF
|
||||
/// @brief Define End-Of-File.
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
/// @brief Define the size of a buffer.
|
||||
#define BUFSIZ 512
|
||||
|
||||
/// Is the signed integer type of the result of subtracting two pointers.
|
||||
typedef long signed int ptrdiff_t;
|
||||
|
||||
/// Define the byte type.
|
||||
typedef unsigned char byte_t;
|
||||
|
||||
/// Define the generic size type.
|
||||
typedef unsigned long size_t;
|
||||
|
||||
/// Define the generic signed size type.
|
||||
typedef long ssize_t;
|
||||
|
||||
/// Define the type of an inode.
|
||||
typedef unsigned int ino_t;
|
||||
|
||||
/// Used for device IDs.
|
||||
typedef unsigned int dev_t;
|
||||
|
||||
/// The type of user-id.
|
||||
typedef unsigned int uid_t;
|
||||
|
||||
/// The type of group-id.
|
||||
typedef unsigned int gid_t;
|
||||
|
||||
/// The type of offset.
|
||||
typedef long int off_t;
|
||||
|
||||
/// The type of mode.
|
||||
typedef unsigned int mode_t;
|
||||
|
||||
/// This data-type is used to set protection bits of pages.
|
||||
typedef unsigned int pgprot_t;
|
||||
|
||||
/// It evaluates to the offset (in bytes) of a given member within
|
||||
/// a struct or union type, an expression of type size_t.
|
||||
#define offsetof(type, member) \
|
||||
((size_t) & (((type *)0)->member))
|
||||
|
||||
/// Retrieve an enclosing structure from a pointer to a nested element.
|
||||
#if 1
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(1 ? (ptr) : &((type *)0)->member) - offsetof(type, member)))
|
||||
#else
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)ptr - offsetof(type, member)))
|
||||
#endif
|
||||
|
||||
/// Returns the alignment, in bytes, of the specified type.
|
||||
#define alignof(type) offsetof( \
|
||||
struct { char c; type member; }, member)
|
||||
|
||||
/// Counts the number of elements of an array.
|
||||
#define count_of(x) ((sizeof(x) / sizeof((x)[0])) / ((size_t)(!(sizeof(x) % sizeof((x)[0])))))
|
||||
|
||||
#define swap(a, b) \
|
||||
do { \
|
||||
typeof(a) temp = (a); \
|
||||
(a) = (b); \
|
||||
(b) = temp; \
|
||||
} while (0)
|
||||
@@ -1,7 +1,6 @@
|
||||
/// MentOS, The Mentoring Operating system project
|
||||
/// @file stdint.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2019 This file is distributed under the MIT License.
|
||||
/// @brief Standard integer data-types.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
@@ -0,0 +1,130 @@
|
||||
/// @file stdio.h
|
||||
/// @brief Standard I/0 functions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stdarg.h"
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief The maximum number of digits of an integer.
|
||||
#define MAX_DIGITS_IN_INTEGER 11
|
||||
/// @brief The size of 'gets' buffer.
|
||||
#define GETS_BUFFERSIZE 255
|
||||
|
||||
#ifndef EOF
|
||||
/// @brief Define the End-Of-File.
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
#define SEEK_SET 0 ///< The file offset is set to offset bytes.
|
||||
#define SEEK_CUR 1 ///< The file offset is set to its current location plus offset bytes.
|
||||
#define SEEK_END 2 ///< The file offset is set to the size of the file plus offset bytes.
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/// @brief Writes the given character to the standard output (stdout).
|
||||
/// @param character The character to send to stdout.
|
||||
void putchar(int character);
|
||||
|
||||
/// @brief Writes the string pointed by str to the standard output (stdout)
|
||||
/// and appends a newline character.
|
||||
/// @param str The string to send to stdout.
|
||||
void puts(const char *str);
|
||||
|
||||
/// @brief Returns the next character from the standard input (stdin).
|
||||
/// @return The character received from stdin.
|
||||
int getchar(void);
|
||||
|
||||
/// @brief Reads characters from the standard input (stdin).
|
||||
/// @param str Where the characters are stored.
|
||||
/// @return The string received from standard input.
|
||||
char *gets(char *str);
|
||||
|
||||
/// @brief Same as getchar but reads from the given file descriptor.
|
||||
/// @param fd The file descriptor from which it reads.
|
||||
/// @return The read character.
|
||||
int fgetc(int fd);
|
||||
|
||||
/// @brief Same as gets but reads from the given file descriptor.
|
||||
/// @param buf The buffer where the string should be placed.
|
||||
/// @param n The amount of characters to read.
|
||||
/// @param fd The file descriptor from which it reads.
|
||||
/// @return The read string.
|
||||
char *fgets(char *buf, int n, int fd);
|
||||
#endif
|
||||
|
||||
/// @brief Convert the given string to an integer.
|
||||
/// @param str The string to convert.
|
||||
/// @return The integer contained inside the string.
|
||||
int atoi(const char *str);
|
||||
|
||||
/// @brief Converts the initial part of `str` to a long int value according to
|
||||
/// the given base, which.
|
||||
/// @param str This is the string containing the integral number.
|
||||
/// @param endptr Set to the character after the numerical value.
|
||||
/// @param base The base must be between 2 and 36 inclusive, or special 0.
|
||||
/// @return Integral number as a long int value, else zero value is returned.
|
||||
long strtol(const char *str, char **endptr, int base);
|
||||
|
||||
/// @brief Write formatted output to stdout.
|
||||
/// @param fmt The format string.
|
||||
/// @param ... The list of arguments.
|
||||
/// @return On success, the total number of characters written is returned.
|
||||
/// On failure, a negative number is returned.
|
||||
int printf(const char *fmt, ...);
|
||||
|
||||
/// @brief Write formatted output to `str`.
|
||||
/// @param str The buffer where the formatted string will be placed.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param ... The list of arguments.
|
||||
/// @return On success, the total number of characters written is returned.
|
||||
/// On failure, a negative number is returned.
|
||||
int sprintf(char *str, const char *fmt, ...);
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/// @brief The same as sprintf, but it putput on file.
|
||||
/// @param fd The file descriptor associated with the file.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param ... The list of arguments.
|
||||
/// @return On success, the total number of characters written is returned.
|
||||
/// On failure, a negative number is returned.
|
||||
int fprintf(int fd, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
/// @brief Write formatted data from variable argument list to string.
|
||||
/// @param str Pointer to a buffer where the resulting C-string is stored.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param args A variable arguments list.
|
||||
/// @return On success, the total number of characters written is returned.
|
||||
/// On failure, a negative number is returned.
|
||||
int vsprintf(char *str, const char *fmt, va_list args);
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/// @brief Read formatted input from stdin.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param ... The list of arguments where the values are stored.
|
||||
/// @return On success, the function returns the number of items of the
|
||||
/// argument list successfully filled. EOF otherwise.
|
||||
int scanf(const char *fmt, ...);
|
||||
|
||||
/// @brief Read formatted data from string.
|
||||
/// @param str String processed as source to retrieve the data.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param ... The list of arguments where the values are stored.
|
||||
/// @return On success, the function returns the number of items of the
|
||||
/// argument list successfully filled. EOF otherwise.
|
||||
int sscanf(const char *str, const char *fmt, ...);
|
||||
|
||||
/// @brief The same as sscanf but the source is a file.
|
||||
/// @param fd The file descriptor associated with the file.
|
||||
/// @param fmt Format string, following the same specifications as printf.
|
||||
/// @param ... The list of arguments where the values are stored.
|
||||
/// @return On success, the function returns the number of items of the
|
||||
/// argument list successfully filled. EOF otherwise.
|
||||
int fscanf(int fd, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
/// @brief Prints a system error message.
|
||||
/// @param s the message we prepend to the actual error message.
|
||||
void perror(const char *s);
|
||||
@@ -0,0 +1,99 @@
|
||||
/// @file stdlib.h
|
||||
/// @brief Useful generic functions and macros.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
#define EXIT_SUCCESS 0 ///< Successful execution of a program.
|
||||
#define EXIT_FAILURE 1 ///< Unsuccessful execution of a program.
|
||||
|
||||
/// @brief Returns the number of usable bytes in the block pointed to by ptr.
|
||||
/// @param ptr The pointer for which we want to retrieve the usable size.
|
||||
/// @return The number of usable bytes in the block of allocated memory
|
||||
/// pointed to by ptr. If ptr is not a valid pointer, 0 is returned.
|
||||
size_t malloc_usable_size(void *ptr);
|
||||
|
||||
/// @brief Provides dynamically allocated memory.
|
||||
/// @param size The amount of memory to allocate.
|
||||
/// @return A pointer to the allocated memory.
|
||||
void *malloc(unsigned int size);
|
||||
|
||||
/// @brief Allocates a block of memory for an array of num elements.
|
||||
/// @param num The number of elements.
|
||||
/// @param size The size of an element.
|
||||
/// @return A pointer to the allocated memory.
|
||||
void *calloc(size_t num, size_t size);
|
||||
|
||||
/// @brief Reallocates the given area of memory.
|
||||
/// @param ptr The pointer to the memory to reallocate.
|
||||
/// @param size The new size for the memory.
|
||||
/// @return A pointer to the new portion of memory.
|
||||
/// @details
|
||||
/// It must be previously allocated by malloc(), calloc() or realloc() and
|
||||
/// not yet freed with a call to free or realloc. Otherwise, the results
|
||||
/// are undefined.
|
||||
void *realloc(void *ptr, size_t size);
|
||||
|
||||
/// @brief Frees dynamically allocated memory.
|
||||
/// @param ptr The pointer to the allocated memory.
|
||||
void free(void *ptr);
|
||||
|
||||
/// @brief Cause an abnormal program termination with core-dump.
|
||||
void abort(void);
|
||||
|
||||
/// @brief Tries to adds the variable to the environment.
|
||||
/// @param name Name of the variable.
|
||||
/// @param value Value of the variable.
|
||||
/// @param overwrite Override existing variable value or not.
|
||||
/// @return Zero on success, or -1 on error with errno indicating the cause.
|
||||
int setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
/// @brief Tries to remove the variable from the environment.
|
||||
/// @param name Name of the variable.
|
||||
/// @return Zero on success, or -1 on error with errno indicating the cause.
|
||||
int unsetenv(const char *name);
|
||||
|
||||
/// @brief Returns the value of the given variable.
|
||||
/// @param name Name of the variable.
|
||||
/// @return A pointer to the value, or NULL if there is no match.
|
||||
char *getenv(const char *name);
|
||||
|
||||
#endif
|
||||
|
||||
/// The maximum value returned by the rand function.
|
||||
#define RAND_MAX ((1U << 31U) - 1U)
|
||||
|
||||
/// @brief Allows to set the seed of the random value generator.
|
||||
/// @param x The new seed.
|
||||
void srand(unsigned x);
|
||||
|
||||
/// @brief Generates a random unsigned integer between 0 and RAND_MAX.
|
||||
/// @return the random value.
|
||||
unsigned rand(void);
|
||||
|
||||
/// @brief Generates a random floating point number between 0 and 1.
|
||||
/// @return the random value.
|
||||
float randf(void);
|
||||
|
||||
/// @brief Generates a random integer between lb and ub.
|
||||
/// @param lb the lower-bound value.
|
||||
/// @param ub the upper-bound value.
|
||||
/// @return the random value.
|
||||
int randint(int lb, int ub);
|
||||
|
||||
/// @brief Generates a random unsigned between lb and ub.
|
||||
/// @param lb the lower-bound value.
|
||||
/// @param ub the upper-bound value.
|
||||
/// @return the random value.
|
||||
unsigned randuint(unsigned lb, unsigned ub);
|
||||
|
||||
/// @brief Generates a random float between lb and ub.
|
||||
/// @param lb the lower-bound value.
|
||||
/// @param ub the upper-bound value.
|
||||
/// @return the random value.
|
||||
float randfloat(float lb, float ub);
|
||||
@@ -0,0 +1,13 @@
|
||||
/// @file strerror.h
|
||||
/// @brief Contains the function that transfornms an errno into a string.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/errno.h>
|
||||
|
||||
/// @brief Returns the string representing the error number.
|
||||
/// @param errnum The error number.
|
||||
/// @return The string representing the error number.
|
||||
char *strerror(int errnum);
|
||||
@@ -0,0 +1,319 @@
|
||||
/// @file string.h
|
||||
/// @brief String routines.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief Copies the first num characters of source to destination.
|
||||
/// @param destination Pointer to the destination array where the content is to be copied.
|
||||
/// @param source String to be copied.
|
||||
/// @param num Maximum number of characters to be copied from source.
|
||||
/// @return destination is returned.
|
||||
char *strncpy(char *destination, const char *source, size_t num);
|
||||
|
||||
/// @brief Compares up to n characters of s1 to those of s2.
|
||||
/// @param s1 First string to be compared.
|
||||
/// @param s2 Second string to be compared.
|
||||
/// @param n Maximum number of characters to compare.
|
||||
/// @return
|
||||
/// Returns an integral value indicating the relationship between the strings:
|
||||
/// <0 the first character that does not match has a lower
|
||||
/// value in s1 than in s2
|
||||
/// 0 the contents of both strings are equal
|
||||
/// >0 the first character that does not match has a greater
|
||||
/// value in s1 than in s2
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/// @brief Case insensitive string compare.
|
||||
/// @param s1 First string to be compared.
|
||||
/// @param s2 Second string to be compared.
|
||||
/// @return
|
||||
/// Returns an integral value indicating the relationship between the strings:
|
||||
/// <0 the first character that does not match has a lower
|
||||
/// value in s1 than in s2
|
||||
/// 0 the contents of both strings are equal
|
||||
/// >0 the first character that does not match has a greater
|
||||
/// value in s1 than in s2
|
||||
int stricmp(const char *s1, const char *s2);
|
||||
|
||||
/// @brief Case-insensitively compare up to n characters of s1 to those of s2.
|
||||
/// @param s1 First string to be compared.
|
||||
/// @param s2 Second string to be compared.
|
||||
/// @param n Maximum number of characters to compare.
|
||||
/// @return
|
||||
/// Returns an integral value indicating the relationship between the strings:
|
||||
/// <0 the first character that does not match has a lower
|
||||
/// value in s1 than in s2
|
||||
/// 0 the contents of both strings are equal
|
||||
/// >0 the first character that does not match has a greater
|
||||
/// value in s1 than in s2
|
||||
int strnicmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/// @brief Returns a pointer to the first occurrence of ch in str.
|
||||
/// @param s The string where the search is performed.
|
||||
/// @param ch Character to be located.
|
||||
/// @return A pointer to the first occurrence of character in str.
|
||||
char *strchr(const char *s, int ch);
|
||||
|
||||
/// @brief Returns a pointer to the last occurrence of ch in str.
|
||||
/// @param s The string where the search is performed.
|
||||
/// @param ch Character to be located.
|
||||
/// @return A pointer to the last occurrence of character in str.
|
||||
char *strrchr(const char *s, int ch);
|
||||
|
||||
/// @brief Returns a pointer to the first occurrence of s2 in s1,
|
||||
/// or NULL if s2 is not part of s1.
|
||||
/// @param s1 String to be scanned
|
||||
/// @param s2 String containing the sequence of characters to match.
|
||||
/// @return A pointer to the first occurrence in s1 of the entire
|
||||
/// sequence of characters specified in s2, or a null pointer
|
||||
/// if the sequence is not present in s1.
|
||||
char *strstr(const char *s1, const char *s2);
|
||||
|
||||
/// @brief Returns the length of the initial portion of string which consists
|
||||
/// only of characters that are part of control.
|
||||
/// @param string String to be scanned.
|
||||
/// @param control String containing the characters to match.
|
||||
/// @return The number of characters in the initial segment of string which
|
||||
/// consist only of characters from control.
|
||||
size_t strspn(const char *string, const char *control);
|
||||
|
||||
/// @brief Calculates the length of the initial segment of string which
|
||||
/// consists entirely of characters not in control.
|
||||
/// @param string String to be scanned.
|
||||
/// @param control String containing the characters to match.
|
||||
/// @return The number of characters in the initial segment of string which
|
||||
/// consist only of characters that are not inside control.
|
||||
size_t strcspn(const char *string, const char *control);
|
||||
|
||||
/// @brief Finds the first character in the string string that matches any
|
||||
/// character specified in control.
|
||||
/// @param string String to be scanned.
|
||||
/// @param control String containing the characters to match.
|
||||
/// @return
|
||||
/// A pointer to the first occurrence in string of any of the characters
|
||||
/// that are part of control, or a null pointer if none of the characters
|
||||
/// of control is found in string before the terminating null-character.
|
||||
char *strpbrk(const char *string, const char *control);
|
||||
|
||||
/// @brief Make a copy of the given string.
|
||||
/// @param s String to duplicate.
|
||||
/// @return On success, returns a pointer to the duplicated string.
|
||||
/// On failure, returns NULL with errno indicating the cause.
|
||||
char *strdup(const char *s);
|
||||
|
||||
/// @brief Make a copy of at most n bytes of the given string.
|
||||
/// @param s String to duplicate.
|
||||
/// @param n The number of character to duplicate.
|
||||
/// @return On success, returns a pointer to the duplicated string.
|
||||
/// On failure, returns NULL with errno indicating the cause.
|
||||
char *strndup(const char *s, size_t n);
|
||||
|
||||
/// @brief Appends a copy of the string src to the string dst.
|
||||
/// @param dst Pointer to the destination array, which should be large enough
|
||||
/// to contain the concatenated resulting string.
|
||||
/// @param src String to be appended. This should not overlap dst.
|
||||
/// @return destination is returned.
|
||||
char *strcat(char *dst, const char *src);
|
||||
|
||||
/// @brief Appends a copy of the string src to the string dst, up to n bytes.
|
||||
/// @param dst Pointer to the destination array, which should be large enough
|
||||
/// to contain the concatenated resulting string.
|
||||
/// @param src String to be appended. This should not overlap dst.
|
||||
/// @param n The number of bytes to copy.
|
||||
/// @return destination is returned.
|
||||
char *strncat(char *dst, const char *src, size_t n);
|
||||
|
||||
/// @brief Fill the string s with the character c.
|
||||
/// @param s The string that you want to fill.
|
||||
/// @param c The character that you want to fill the string with.
|
||||
/// @return The address of the string, s.
|
||||
char *strset(char *s, int c);
|
||||
|
||||
/// @brief Fill the string s with the character c, up to the given length n.
|
||||
/// @param s The string that you want to fill.
|
||||
/// @param c The character that you want to fill the string with.
|
||||
/// @param n The maximum number of bytes to fill.
|
||||
/// @return The address of the string, s.
|
||||
char *strnset(char *s, int c, size_t n);
|
||||
|
||||
/// @brief Reverse the string s.
|
||||
/// @param s The given string which is needed to be reversed.
|
||||
/// @return The address of the string, s.
|
||||
char *strrev(char *s);
|
||||
|
||||
/// @brief Splits string into tokens.
|
||||
/// @param str String to truncate.
|
||||
/// @param delim String containing the delimiter characters.
|
||||
/// @return If a token is found, a pointer to the beginning of the token.
|
||||
/// Otherwise, a null pointer.
|
||||
/// @details
|
||||
/// Notice that str is modified by being broken into smaller strings (tokens).
|
||||
/// A null pointer may be specified, in which case the function continues
|
||||
/// scanning where a previous successful call to the function ended.
|
||||
char *strtok(char *str, const char *delim);
|
||||
|
||||
/// @brief This function is a reentrant version strtok().
|
||||
/// @param str String to truncate.
|
||||
/// @param delim String containing the delimiter characters.
|
||||
/// @param saveptr Pointer used internally to maintain context between calls.
|
||||
/// @return
|
||||
/// @details
|
||||
/// The saveptr argument is a pointer to a char * variable that is used
|
||||
/// internally by strtok_r() in order to maintain context between successive
|
||||
/// calls that parse the same string.
|
||||
/// On the first call to strtok_r(), str should point to the string to be
|
||||
/// parsed, and the value of saveptr is ignored. In subsequent calls, str
|
||||
/// should be NULL, and saveptr should be unchanged since the previous call.
|
||||
char *strtok_r(char *str, const char *delim, char **saveptr);
|
||||
|
||||
/// @brief Parses the string using the separator, and at each call it saves the
|
||||
/// parsed token in buffer. The pointer `string` will be modified.
|
||||
/// @param string cursor used to parse the string, it will be modified.
|
||||
/// @param separators the list of separators we are using.
|
||||
/// @param buffer the buffer where we save the parsed token.
|
||||
/// @param buflen the length of the buffer.
|
||||
/// @return 1 if we still have things to parse, 0 if we finished parsing.
|
||||
int tokenize(const char *string, char *separators, size_t *offset, char *buffer, ssize_t buflen);
|
||||
|
||||
/// @brief Copies the values of num bytes from the location pointed by source
|
||||
/// to the memory block pointed by destination.
|
||||
/// @param dst Pointer to the destination array where the content is to be
|
||||
/// copied, type-casted to a pointer of type void*.
|
||||
/// @param src Pointer to the source of data to be copied, type-casted to
|
||||
/// a pointer of type const void*.
|
||||
/// @param n Number of bytes to copy.
|
||||
/// @return A pointer to dst is returned.
|
||||
void *memmove(void *dst, const void *src, size_t n);
|
||||
|
||||
/// @brief Searches for the first occurrence of the character c (an unsigned
|
||||
/// char) in the first n bytes of the string pointed to, by the
|
||||
/// argument str.
|
||||
/// @param ptr Pointer to the block of memory where the search is performed.
|
||||
/// @param c Value to be located.
|
||||
/// @param n Number of bytes to be analyzed.
|
||||
/// @return A pointer to the first occurrence of value in the block of memory.
|
||||
void *memchr(const void *ptr, int c, size_t n);
|
||||
|
||||
/// @brief Converts a given string into lowercase.
|
||||
/// @param s String which we want to convert into lowercase.
|
||||
/// @return A pointer to s.
|
||||
char *strlwr(char *s);
|
||||
|
||||
/// @brief Converts a given string into uppercase.
|
||||
/// @param s String which we want to convert into uppercase.
|
||||
/// @return A pointer to s.
|
||||
char *strupr(char *s);
|
||||
|
||||
/// @brief The memccpy function copies no more than n bytes from memory
|
||||
/// area src to memory area dest, stopping when the character c is
|
||||
/// found.
|
||||
/// @param dst Points to the destination memory area.
|
||||
/// @param src Points to the source memory area.
|
||||
/// @param c The delimiter used to stop.
|
||||
/// @param n The maximum number of copied bytes.
|
||||
/// @return A pointer to the next character in dst after c, or NULL if c
|
||||
/// was not found in the first n characters of src.
|
||||
void *memccpy(void *dst, const void *src, int c, size_t n);
|
||||
|
||||
/// @brief Copy a block of memory, handling overlap.
|
||||
/// @param dst Pointer to the destination.
|
||||
/// @param src Pointer to the source.
|
||||
/// @param num Number of bytes to be copied.
|
||||
/// @return Pointer to the destination.
|
||||
void *memcpy(void *dst, const void *src, size_t num);
|
||||
|
||||
/// @brief Compares the first n bytes of str1 and str2.
|
||||
/// @param ptr1 First pointer to block of memory.
|
||||
/// @param ptr2 Second pointer to block of memory.
|
||||
/// @param n Number of bytes to compare.
|
||||
/// @return
|
||||
/// Returns an integral value indicating the relationship between
|
||||
/// the memory blocks:
|
||||
/// <0 the first byte that does not match has a lower
|
||||
/// value in ptr1 than in ptr2
|
||||
/// 0 the contents of both memory blocks are equal
|
||||
/// >0 the first byte that does not match has a greater
|
||||
/// value in ptr1 than in ptr2
|
||||
int memcmp(const void *ptr1, const void *ptr2, size_t n);
|
||||
|
||||
/// @brief Sets the first num bytes of the block of memory pointed by ptr
|
||||
/// to the specified value.
|
||||
/// @param ptr Pointer to the block of memory to set.
|
||||
/// @param value Value to be set.
|
||||
/// @param num Number of bytes to be set to the given value.
|
||||
/// @return The same ptr.
|
||||
void *memset(void *ptr, int value, size_t num);
|
||||
|
||||
/// @brief Copy the string src into the array dst.
|
||||
/// @param dst The destination array where the content is to be copied.
|
||||
/// @param src String to be copied.
|
||||
/// @return A pointer to dst is returned.
|
||||
char *strcpy(char *dst, const char *src);
|
||||
|
||||
/// @brief Checks if the two strings are equal.
|
||||
/// @param s1 First string to be compared.
|
||||
/// @param s2 Second string to be compared.
|
||||
/// @return
|
||||
/// Returns an integral value indicating the relationship between the strings:
|
||||
/// <0 the first character that does not match has a lower
|
||||
/// value in s1 than in s2
|
||||
/// 0 the contents of both strings are equal
|
||||
/// >0 the first character that does not match has a greater
|
||||
/// value in s1 than in s2
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
|
||||
/// @brief Returns the length of the string s.
|
||||
/// @param s Pointer to the null-terminated byte string to be examined.
|
||||
/// @return The length of the null-terminated string str.
|
||||
size_t strlen(const char *s);
|
||||
|
||||
/// @brief Returns the number of characters inside s, excluding the
|
||||
/// terminating null byte ('\0'), but at most count.
|
||||
/// @param s Pointer to the null-terminated byte string to be examined.
|
||||
/// @param maxlen The upperbound on the length.
|
||||
/// @return Returns strlen(s), if that is less than maxlen, or maxlen
|
||||
/// if there is no null terminating ('\0') among the first maxlen
|
||||
/// characters pointed to by s.
|
||||
size_t strnlen(const char *s, size_t maxlen);
|
||||
|
||||
/// @brief Removes any whitespace characters from the beginning and end of str.
|
||||
/// @param str The string to trim.
|
||||
/// @return A pointer to str.
|
||||
char *trim(char *str);
|
||||
|
||||
/// @brief Separate the given string based on a given delimiter.
|
||||
/// @param stringp The string to separate.
|
||||
/// @param delim The delimiter used to separate the string.
|
||||
/// @return Returns a pointer to stringp.
|
||||
/// @details
|
||||
/// Finds the first token in stringp, that is delimited by one of the bytes in
|
||||
/// the string delim. This token is terminated by overwriting the delimiter
|
||||
/// with a null byte ('\0'), and *stringp is updated to point past the token.
|
||||
/// In case no delimiter was found, the token is taken to be the entire string
|
||||
/// *stringp, and *stringp is made NULL.
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
|
||||
/// @brief Move the number "num" into a string.
|
||||
/// @param buffer The string containing the number.
|
||||
/// @param num The number to convert.
|
||||
/// @param base The base used to convert.
|
||||
/// @return A pointer to buffer.
|
||||
char *itoa(char *buffer, unsigned int num, unsigned int base);
|
||||
|
||||
/// @brief Replaces the occurrences of find with replace inside str.
|
||||
/// @param str The string to manipulate.
|
||||
/// @param find The character to replace.
|
||||
/// @param replace The character used to replace.
|
||||
/// @return A pointer to str.
|
||||
char *replace_char(char *str, char find, char replace);
|
||||
|
||||
/// @brief Converts a file mode (the type and permission information associated
|
||||
/// with an inode) into a symbolic string which is stored in the location
|
||||
/// referenced by p.
|
||||
/// @param mode File mode that encodes access permissions and file type.
|
||||
/// @param p Buffer used to hold the string representation of file mode m.
|
||||
void strmode(mode_t mode, char *p);
|
||||
@@ -0,0 +1,50 @@
|
||||
/// @file bitops.h
|
||||
/// @brief Bitmasks functions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define bit_set(V, B) ((V) | (1U << (B))) ///< Sets the given bit.
|
||||
#define bit_clear(V, B) ((V) & ~(1U << (B))) ///< Clears the given bit.
|
||||
#define bit_flip(V, B) ((V) ^ (1U << (B))) ///< Flips the given bit.
|
||||
#define bit_check(V, B) ((V) & (1U << (B))) ///< Checks if the given bit is 1.
|
||||
#define bit_toggle(V, B, C) ((C) ? bit_set(V, B) : bit_clear(V, B)) ///< Sets the given bit based on control bit C.
|
||||
#define bit_set_assign(V, B) ((V) |= (1U << (B))) ///< Sets the given bit, permanently.
|
||||
#define bit_clear_assign(V, B) ((V) &= ~(1U << (B))) ///< Clears the given bit, permanently.
|
||||
#define bit_flip_assign(V, B) ((V) ^= (1U << (B))) ///< Flips the given bit, permanently.
|
||||
#define bit_toggle_assign(V, B, C) ((C) ? bit_set_assign(V, B) : bit_clear_assign(V, B)) ///< Sets the given bit based on control bit C.
|
||||
|
||||
#define bitmask_set(V, M) ((V) | (M)) ///< Sets the bits identified by the mask.
|
||||
#define bitmask_clear(V, M) ((V) & ~(M)) ///< Clears the bits identified by the mask.
|
||||
#define bitmask_flip(V, M) ((V) ^ (M)) ///< Flips the bits identified by the mask.
|
||||
#define bitmask_check(V, M) ((V) & (M)) ///< Checks if the bits identified by the mask are all 1.
|
||||
#define bitmask_set_assign(V, M) ((V) |= (M)) ///< Sets the bits identified by the mask, permanently.
|
||||
#define bitmask_clear_assign(V, M) ((V) &= ~(M)) ///< Clears the bits identified by the mask, permanently.
|
||||
#define bitmask_flip_assign(V, M) ((V) ^= (M)) ///< Flips the bits identified by the mask, permanently.
|
||||
|
||||
/// @brief Finds the first bit at zero, starting from the less significative bit.
|
||||
/// @param value the value we need to analyze.
|
||||
/// @return the position of the first zero bit.
|
||||
static inline int find_first_zero(unsigned long value)
|
||||
{
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (!bit_check(value, i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief Finds the first bit not zero, starting from the less significative bit.
|
||||
/// @param value the value we need to analyze.
|
||||
/// @return the position of the first non-zero bit.
|
||||
static inline int find_first_non_zero(unsigned long value)
|
||||
{
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (bit_check(value, i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/// @file dirent.h
|
||||
/// @brief Functions used to manage directories.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "limits.h"
|
||||
#include "stddef.h"
|
||||
|
||||
/// File types for `d_type'.
|
||||
enum {
|
||||
DT_UNKNOWN = 0,
|
||||
DT_FIFO = 1,
|
||||
DT_CHR = 2,
|
||||
DT_DIR = 4,
|
||||
DT_BLK = 6,
|
||||
DT_REG = 8,
|
||||
DT_LNK = 10,
|
||||
DT_SOCK = 12,
|
||||
DT_WHT = 14
|
||||
};
|
||||
|
||||
/// @brief Characters describing the direactory entry.
|
||||
static const char dt_char_array[] = {
|
||||
'?', // DT_UNKNOWN = 0,
|
||||
'p', // DT_FIFO = 1,
|
||||
'c', // DT_CHR = 2,
|
||||
'*',
|
||||
'd', // DT_DIR = 4,
|
||||
'*',
|
||||
'b', // DT_BLK = 6,
|
||||
'*',
|
||||
'-', // DT_REG = 8,
|
||||
'*',
|
||||
'l', // DT_LNK = 10,
|
||||
'*',
|
||||
's', // DT_SOCK = 12,
|
||||
'*',
|
||||
'?', // DT_WHT = 14
|
||||
};
|
||||
|
||||
/// Directory entry.
|
||||
typedef struct dirent_t {
|
||||
ino_t d_ino; ///< Inode number.
|
||||
off_t d_off; ///< Offset to next linux_dirent.
|
||||
unsigned short d_reclen; ///< Length of this linux_dirent.
|
||||
unsigned short d_type; ///< type of the directory entry.
|
||||
char d_name[NAME_MAX]; ///< Filename (null-terminated)
|
||||
} dirent_t;
|
||||
@@ -0,0 +1,137 @@
|
||||
/// @file errno.h
|
||||
/// @brief System call errors definition.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
extern int *__geterrno(void);
|
||||
|
||||
/// Provide easy access to the error number.
|
||||
#define errno (*__geterrno())
|
||||
|
||||
#define EPERM 1 ///< Operation not permitted.
|
||||
#define ENOENT 2 ///< No such file or directory.
|
||||
#define ESRCH 3 ///< No such process.
|
||||
#define EINTR 4 ///< Interrupted system call.
|
||||
#define EIO 5 ///< I/O error.
|
||||
#define ENXIO 6 ///< No such device or address.
|
||||
#define E2BIG 7 ///< Arg list too long.
|
||||
#define ENOEXEC 8 ///< Exec format error.
|
||||
#define EBADF 9 ///< Bad file number.
|
||||
#define ECHILD 10 ///< No child processes.
|
||||
#define EAGAIN 11 ///< Resource temporarily unavailable.
|
||||
#define ENOMEM 12 ///< Out of memory.
|
||||
#define EACCES 13 ///< Permission denied.
|
||||
#define EFAULT 14 ///< Bad address.
|
||||
#define ENOTBLK 15 ///< Block device required.
|
||||
#define EBUSY 16 ///< Device or resource busy.
|
||||
#define EEXIST 17 ///< File exists.
|
||||
#define EXDEV 18 ///< Cross-device link.
|
||||
#define ENODEV 19 ///< No such device.
|
||||
#define ENOTDIR 20 ///< Not a directory.
|
||||
#define EISDIR 21 ///< Is a directory.
|
||||
#define EINVAL 22 ///< Invalid argument.
|
||||
#define ENFILE 23 ///< File table overflow.
|
||||
#define EMFILE 24 ///< Too many open files.
|
||||
#define ENOTTY 25 ///< Not a typewriter.
|
||||
#define ETXTBSY 26 ///< Text file busy.
|
||||
#define EFBIG 27 ///< File too large.
|
||||
#define ENOSPC 28 ///< No space left on device.
|
||||
#define ESPIPE 29 ///< Illegal seek.
|
||||
#define EROFS 30 ///< Read-only file system.
|
||||
#define EMLINK 31 ///< Too many links.
|
||||
#define EPIPE 32 ///< Broken pipe.
|
||||
#define EDOM 33 ///< Math argument out of domain of func.
|
||||
#define ERANGE 34 ///< Math result not representable.
|
||||
#define EDEADLK 35 ///< Resource deadlock would occur.
|
||||
#define ENAMETOOLONG 36 ///< File name too long.
|
||||
#define ENOLCK 37 ///< No record locks available.
|
||||
#define ENOSYS 38 ///< Function not implemented.
|
||||
#define ENOTEMPTY 39 ///< Directory not empty.
|
||||
#define ELOOP 40 ///< Too many symbolic links encountered.
|
||||
#define EWOULDBLOCK EAGAIN ///< Operation would block.
|
||||
#define ENOMSG 42 ///< No message of desired type.
|
||||
#define EIDRM 43 ///< Identifier removed.
|
||||
#define ECHRNG 44 ///< Channel number out of range.
|
||||
#define EL2NSYNC 45 ///< Level 2 not synchronized.
|
||||
#define EL3HLT 46 ///< Level 3 halted.
|
||||
#define EL3RST 47 ///< Level 3 reset.
|
||||
#define ELNRNG 48 ///< Link number out of range.
|
||||
#define EUNATCH 49 ///< Protocol driver not attached.
|
||||
#define ENOCSI 50 ///< No CSI structure available.
|
||||
#define EL2HLT 51 ///< Level 2 halted.
|
||||
#define EBADE 52 ///< Invalid exchange.
|
||||
#define EBADR 53 ///< Invalid request descriptor.
|
||||
#define EXFULL 54 ///< Exchange full.
|
||||
#define ENOANO 55 ///< No anode.
|
||||
#define EBADRQC 56 ///< Invalid request code.
|
||||
#define EBADSLT 57 ///< Invalid slot.
|
||||
#define EDEADLOCK EDEADLK ///< Resource deadlock would occur.
|
||||
#define EBFONT 59 ///< Bad font file format.
|
||||
#define ENOSTR 60 ///< Device not a stream.
|
||||
#define ENODATA 61 ///< No data available.
|
||||
#define ETIME 62 ///< Timer expired.
|
||||
#define ENOSR 63 ///< Out of streams resources.
|
||||
#define ENONET 64 ///< Machine is not on the network.
|
||||
#define ENOPKG 65 ///< Package not installed.
|
||||
#define EREMOTE 66 ///< Object is remote.
|
||||
#define ENOLINK 67 ///< Link has been severed.
|
||||
#define EADV 68 ///< Advertise error.
|
||||
#define ESRMNT 69 ///< Srmount error.
|
||||
#define ECOMM 70 ///< Communication error on send.
|
||||
#define EPROTO 71 ///< Protocol error.
|
||||
#define EMULTIHOP 72 ///< Multihop attempted.
|
||||
#define EDOTDOT 73 ///< RFS specific error.
|
||||
#define EBADMSG 74 ///< Not a data message.
|
||||
#define EOVERFLOW 75 ///< Value too large for defined data type.
|
||||
#define ENOTUNIQ 76 ///< Name not unique on network.
|
||||
#define EBADFD 77 ///< File descriptor in bad state.
|
||||
#define EREMCHG 78 ///< Remote address changed.
|
||||
#define ELIBACC 79 ///< Can not access a needed shared library.
|
||||
#define ELIBBAD 80 ///< Accessing a corrupted shared library.
|
||||
#define ELIBSCN 81 ///< .lib section in a.out corrupted.
|
||||
#define ELIBMAX 82 ///< Attempting to link in too many shared libraries.
|
||||
#define ELIBEXEC 83 ///< Cannot exec a shared library directly.
|
||||
#define EILSEQ 84 ///< Illegal byte sequence.
|
||||
#define ERESTART 85 ///< Interrupted system call should be restarted.
|
||||
#define ESTRPIPE 86 ///< Streams pipe error.
|
||||
#define EUSERS 87 ///< Too many users.
|
||||
#define ENOTSOCK 88 ///< Socket operation on non-socket.
|
||||
#define EDESTADDRREQ 89 ///< Destination address required.
|
||||
#define EMSGSIZE 90 ///< Message too long.
|
||||
#define EPROTOTYPE 91 ///< Protocol wrong type for socket.
|
||||
#define ENOPROTOOPT 92 ///< Protocol not available.
|
||||
#define EPROTONOSUPPORT 93 ///< Protocol not supported.
|
||||
#define ESOCKTNOSUPPORT 94 ///< Socket type not supported.
|
||||
#define EOPNOTSUPP 95 ///< Operation not supported on transport endpoint.
|
||||
#define EPFNOSUPPORT 96 ///< Protocol family not supported.
|
||||
#define EAFNOSUPPORT 97 ///< Address family not supported by protocol.
|
||||
#define EADDRINUSE 98 ///< Address already in use.
|
||||
#define EADDRNOTAVAIL 99 ///< Cannot assign requested address.
|
||||
#define ENETDOWN 100 ///< Network is down.
|
||||
#define ENETUNREACH 101 ///< Network is unreachable.
|
||||
#define ENETRESET 102 ///< Network dropped connection because of reset.
|
||||
#define ECONNABORTED 103 ///< Software caused connection abort.
|
||||
#define ECONNRESET 104 ///< Connection reset by peer.
|
||||
#define ENOBUFS 105 ///< No buffer space available.
|
||||
#define EISCONN 106 ///< Transport endpoint is already connected.
|
||||
#define ENOTCONN 107 ///< Transport endpoint is not connected.
|
||||
#define ESHUTDOWN 108 ///< Cannot send after transport endpoint shutdown.
|
||||
#define ETOOMANYREFS 109 ///< Too many references: cannot splice.
|
||||
#define ETIMEDOUT 110 ///< Connection timed out.
|
||||
#define ECONNREFUSED 111 ///< Connection refused.
|
||||
#define EHOSTDOWN 112 ///< Host is down.
|
||||
#define EHOSTUNREACH 113 ///< No route to host.
|
||||
#define EALREADY 114 ///< Operation already in progress.
|
||||
#define EINPROGRESS 115 ///< Operation now in progress.
|
||||
#define ESTALE 116 ///< Stale NFS file handle.
|
||||
#define EUCLEAN 117 ///< Structure needs cleaning.
|
||||
#define ENOTNAM 118 ///< Not a XENIX named type file.
|
||||
#define ENAVAIL 119 ///< No XENIX semaphores available.
|
||||
#define EISNAM 120 ///< Is a named type file.
|
||||
#define EREMOTEIO 121 ///< Remote I/O error.
|
||||
#define EDQUOT 122 ///< Quota exceeded.
|
||||
#define ENOMEDIUM 123 ///< No medium found.
|
||||
#define EMEDIUMTYPE 124 ///< Wrong medium type.
|
||||
#define ENOTSCHEDULABLE 125 ///< The periodc process cannot be scheduled.
|
||||
@@ -0,0 +1,14 @@
|
||||
/// @file ioctl.h
|
||||
/// @brief Input/Output ConTroL (IOCTL) functions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// @brief Perform the I/O control operation specified by REQUEST on FD.
|
||||
/// One argument may follow; its presence and type depend on REQUEST.
|
||||
/// @param fd Must be an open file descriptor.
|
||||
/// @param request The device-dependent request code
|
||||
/// @param data An untyped pointer to memory.
|
||||
/// @return Return value depends on REQUEST. Usually -1 indicates error.
|
||||
int ioctl(int fd, unsigned long int request, void *data);
|
||||
@@ -0,0 +1,43 @@
|
||||
/// @file ipc.h
|
||||
/// @brief Inter-Process Communication (IPC) structures.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "stddef.h"
|
||||
|
||||
#define IPC_CREAT 01000 ///< Create key if key does not exist.
|
||||
#define IPC_EXCL 02000 ///< Fail if key exists.
|
||||
#define IPC_NOWAIT 04000 ///< Return error on wait.
|
||||
#define IPC_RMID 0 ///< Remove identifier.
|
||||
#define IPC_SET 1 ///< Set `ipc_perm' options.
|
||||
#define IPC_STAT 2 ///< Get `ipc_perm' options.
|
||||
#define IPC_INFO 3 ///< See ipcs.
|
||||
|
||||
#define IPC_PRIVATE ((key_t)0) ///< assures getting a new ipc_key.
|
||||
|
||||
/// @brief Permission details of an IPC object.
|
||||
struct ipc_perm {
|
||||
/// Key associated to the IPC.
|
||||
key_t key;
|
||||
/// Effective UID of owner.
|
||||
uid_t uid;
|
||||
/// Effective GID of owner.
|
||||
gid_t gid;
|
||||
/// Effective UID of creator.
|
||||
uid_t cuid;
|
||||
/// Effective GID of creator.
|
||||
gid_t cgid;
|
||||
/// Permissions.
|
||||
unsigned short mode;
|
||||
/// Sequence number.
|
||||
unsigned short __seq;
|
||||
};
|
||||
|
||||
/// @brief Returns a possible IPC key based upon the filepath and the id.
|
||||
/// @param path The file path.
|
||||
/// @param id the project id.
|
||||
/// @return the IPC key.
|
||||
key_t ftok(char *path, int id);
|
||||
@@ -0,0 +1,17 @@
|
||||
/// @file kernel_levels.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Integer equivalents of KERN_<LEVEL>
|
||||
#define LOGLEVEL_DEFAULT (-1) ///< default-level messages.
|
||||
#define LOGLEVEL_EMERG 0 ///< system is unusable.
|
||||
#define LOGLEVEL_ALERT 1 ///< action must be taken immediately.
|
||||
#define LOGLEVEL_CRIT 2 ///< critical conditions.
|
||||
#define LOGLEVEL_ERR 3 ///< error conditions.
|
||||
#define LOGLEVEL_WARNING 4 ///< warning conditions.
|
||||
#define LOGLEVEL_NOTICE 5 ///< normal but significant condition.
|
||||
#define LOGLEVEL_INFO 6 ///< informational.
|
||||
#define LOGLEVEL_DEBUG 7 ///< debug-level messages.
|
||||
@@ -0,0 +1,199 @@
|
||||
/// @file list_head.h
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
/// @brief Structure used to implement the list_head data structure.
|
||||
typedef struct list_head {
|
||||
/// @brief The previous element.
|
||||
struct list_head *prev;
|
||||
/// @brief The subsequent element.
|
||||
struct list_head *next;
|
||||
} list_head;
|
||||
|
||||
/// @brief Get the struct for this entry.
|
||||
/// @param ptr The &list_head pointer.
|
||||
/// @param type The type of the struct this is embedded in.
|
||||
/// @param member The name of the list_head within the struct.
|
||||
#define list_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
|
||||
/// @brief Iterates over a list.
|
||||
/// @param pos the name of the iterator used to visit the list.
|
||||
/// @param head the head for your list.
|
||||
#define list_for_each(pos, head) \
|
||||
for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next)
|
||||
|
||||
/// @brief Iterates over a list safe against removal of list entry.
|
||||
/// @param pos the name of the iterator used to visit the list.
|
||||
/// @param store another list iterator to use as temporary storage.
|
||||
/// @param head the head for your list.
|
||||
#define list_for_each_safe(pos, store, head) \
|
||||
for ((pos) = (head)->next, (store) = (pos)->next; (pos) != (head); \
|
||||
(pos) = (store), (store) = (pos)->next)
|
||||
|
||||
/// @brief Iterates over a list, but declares the iterator.
|
||||
/// @param pos the name of the iterator used to visit the list.
|
||||
/// @param head the head for your list.
|
||||
#define list_for_each_decl(pos, head) \
|
||||
for (list_head * (pos) = (head)->next; (pos) != (head); (pos) = (pos)->next)
|
||||
|
||||
/// @brief Iterates over a list backwards.
|
||||
/// @param pos the name of the iterator used to visit the list.
|
||||
/// @param head the head for your list.
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for ((pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev)
|
||||
|
||||
/// @brief Iterates over a list backwards, but declares the iterator.
|
||||
/// @param pos the name of the iterator used to visit the list.
|
||||
/// @param head the head for your list.
|
||||
#define list_for_each_prev_decl(pos, head) \
|
||||
for (list_head * (pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev)
|
||||
|
||||
/// @brief Initializes the list_head.
|
||||
/// @param head The head of your list.
|
||||
static inline void list_head_init(list_head *head)
|
||||
{
|
||||
head->next = head->prev = head;
|
||||
}
|
||||
|
||||
/// @brief Tests whether the given list is empty.
|
||||
/// @param head The list to check.
|
||||
/// @return 1 if empty, 0 otherwise.
|
||||
static inline int list_head_empty(const list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/// @brief Computes the size of the list.
|
||||
/// @param head The head of the list.
|
||||
/// @return the size of the list.
|
||||
static inline unsigned list_head_size(const list_head *head)
|
||||
{
|
||||
unsigned size = 0;
|
||||
if (!list_head_empty(head)) {
|
||||
list_for_each_decl(it, head) size += 1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/// @brief Insert the new entry after the given location.
|
||||
/// @param new_entry the new element we want to insert.
|
||||
/// @param location the element after which we insert.
|
||||
static inline void list_head_insert_after(list_head *new_entry, list_head *location)
|
||||
{
|
||||
// We store the old `next` element.
|
||||
list_head *old_next = location->next;
|
||||
// We insert our element.
|
||||
location->next = new_entry;
|
||||
// We update the `previous` link of our new entry.
|
||||
new_entry->prev = location;
|
||||
// We update the `next` link of our new entry.
|
||||
new_entry->next = old_next;
|
||||
// We link the previously `next` element to our new entry.
|
||||
old_next->prev = new_entry;
|
||||
}
|
||||
|
||||
/// @brief Insert the new entry before the given location.
|
||||
/// @param new_entry the new element we want to insert.
|
||||
/// @param location the element after which we insert.
|
||||
static inline void list_head_insert_before(list_head *new_entry, list_head *location)
|
||||
{
|
||||
// We store the old `previous` element.
|
||||
list_head *old_prev = location->prev;
|
||||
// We link the old `previous` element to our new entry.
|
||||
old_prev->next = new_entry;
|
||||
// We update the `previous` link of our new entry.
|
||||
new_entry->prev = old_prev;
|
||||
// We update the `next` link of our new entry.
|
||||
new_entry->next = location;
|
||||
// Finally, we close the link with the old insertion location element.
|
||||
location->prev = new_entry;
|
||||
}
|
||||
|
||||
/// @brief Removes the given entry from the list it is contained in.
|
||||
/// @param entry the entry we want to remove.
|
||||
static inline void list_head_remove(list_head *entry)
|
||||
{
|
||||
// Check if the element is actually in a list.
|
||||
if (!list_head_empty(entry)) {
|
||||
// We link the `previous` element to the `next` one.
|
||||
entry->prev->next = entry->next;
|
||||
// We link the `next` element to the `previous` one.
|
||||
entry->next->prev = entry->prev;
|
||||
// We initialize the entry again.
|
||||
list_head_init(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Removes an element from the list, it's used when we have a possibly
|
||||
/// null list pointer and want to pop an element from it.
|
||||
/// @param head the head of the list.
|
||||
/// @return a list_head pointing to the element we removed, NULL on failure.
|
||||
static inline list_head *list_head_pop(list_head *head)
|
||||
{
|
||||
// Check if the list is not empty.
|
||||
if (!list_head_empty(head)) {
|
||||
// Store the pointer.
|
||||
list_head *value = head->next;
|
||||
// Remove the element from the list.
|
||||
list_head_remove(head->next);
|
||||
// Return the pointer to the element.
|
||||
return value;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// @brief Append the `secondary` list at the end of the `main` list.
|
||||
/// @param main the main list where we append the secondary list.
|
||||
/// @param secondary the secondary list, which gets appended, and re-initialized as empty.
|
||||
static inline void list_head_append(list_head *main, list_head *secondary)
|
||||
{
|
||||
// Check that both lists are actually filled with entries.
|
||||
if (!list_head_empty(main) && !list_head_empty(secondary)) {
|
||||
// Connect the last element of the main list to the first one of the secondary list.
|
||||
main->prev->next = secondary->next;
|
||||
// Connect the first element of the secondary list to the last one of the main list.
|
||||
secondary->next->prev = main->prev;
|
||||
|
||||
// Connect the last element of the secondary list to our main.
|
||||
secondary->prev->next = main;
|
||||
// Connect our main to the last element of the secondary list.
|
||||
main->prev = secondary->prev;
|
||||
|
||||
// Re-initialize the secondary list.
|
||||
list_head_init(secondary);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Replaces entry1 with entry2, entry1 will be removed from the list.
|
||||
/// @param entry1 the first entry to remove.
|
||||
/// @param entry2 the second entry which will take the place of the first entry.
|
||||
static inline void list_head_replace(list_head *entry1, list_head *entry2)
|
||||
{
|
||||
// First we need to remove the second entry.
|
||||
list_head_remove(entry2);
|
||||
// Then, we can place second entry where the first entry is.
|
||||
entry2->next = entry1->next;
|
||||
entry2->next->prev = entry2;
|
||||
entry2->prev = entry1->prev;
|
||||
entry2->prev->next = entry2;
|
||||
// Re-initialize the first entry.
|
||||
list_head_init(entry1);
|
||||
}
|
||||
|
||||
/// @brief Swaps entry1 and entry2 inside the list.
|
||||
/// @param entry1 the first entry.
|
||||
/// @param entry2 the second entry.
|
||||
static inline void list_head_swap(list_head *entry1, list_head *entry2)
|
||||
{
|
||||
list_head *pos = entry2->prev;
|
||||
list_head_replace(entry1, entry2);
|
||||
if (pos == entry1) {
|
||||
pos = entry2;
|
||||
}
|
||||
list_head_insert_after(entry1, pos);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/// @file list_head_algorithm.h
|
||||
/// @author Enrico Fraccaroli (enry.frak@gmail.com)
|
||||
/// @brief Some general algorithm that might come in handy while using list_head.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "list_head.h"
|
||||
|
||||
/// @brief list_head comparison function.
|
||||
typedef int (*list_head_compare)(const list_head *, const list_head *);
|
||||
|
||||
/// @brief -
|
||||
/// @param list
|
||||
/// @param compare
|
||||
static inline void list_head_sort(list_head *list, list_head_compare compare)
|
||||
{
|
||||
list_head *current = NULL, *index = NULL, *next = NULL;
|
||||
// Check whether list is empty
|
||||
if (!list_head_empty(list)) {
|
||||
// Keeps track if we need to restart the outer loop.
|
||||
int restart = 0;
|
||||
// Current will point to head
|
||||
for (current = list->next; current->next != list;) {
|
||||
// Save pointer to next.
|
||||
next = current->next;
|
||||
// Reset restart flag.
|
||||
restart = 0;
|
||||
// Index will point to node next to current
|
||||
for (index = current->next; index != list; index = index->next) {
|
||||
// If current's data is greater than index's data, swap the data of
|
||||
// current and index
|
||||
if (compare(current, index)) {
|
||||
list_head_swap(index, current);
|
||||
restart = 1;
|
||||
}
|
||||
}
|
||||
// Check if we need to restart.
|
||||
if (restart) {
|
||||
current = list->next;
|
||||
} else {
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/// @file mman.h
|
||||
/// @author Enrico Fraccaroli (enry.frak@gmail.com)
|
||||
/// @brief Functions for managing mappings in virtual address space.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
#define PROT_READ 0x1 ///< Page can be read.
|
||||
#define PROT_WRITE 0x2 ///< Page can be written.
|
||||
#define PROT_EXEC 0x4 ///< Page can be executed.
|
||||
|
||||
#define MAP_SHARED 0x01 ///< The memory is shared.
|
||||
#define MAP_PRIVATE 0x02 ///< The memory is private.
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
|
||||
|
||||
int munmap(void *addr, size_t length);
|
||||
|
||||
#else
|
||||
|
||||
void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
|
||||
|
||||
int sys_munmap(void *addr, size_t length);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
/// @file msg.h
|
||||
/// @brief Definition of structure for managing message queues.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/ipc.h"
|
||||
#include "stddef.h"
|
||||
#include "sys/types.h"
|
||||
#include "time.h"
|
||||
|
||||
/// The maximum size for a message text.
|
||||
#define MSGMAX 8192
|
||||
/// The default maximum size in bytes of a message queue.
|
||||
#define MSGMNB 16384
|
||||
|
||||
/// Specify that we should not treat as an error if the message we are trying to
|
||||
/// return to the user, is too big. That message will be truncated to fit the
|
||||
/// user-defined reading buffer. If not specified, the message is kept in the
|
||||
/// queue, and an error is returned.
|
||||
#define MSG_NOERROR 010000
|
||||
|
||||
/// @brief Buffer to use with the message queue IPC.
|
||||
struct msgbuf {
|
||||
/// Type of the message.
|
||||
long mtype;
|
||||
/// Text of the message.
|
||||
char mtext[1];
|
||||
};
|
||||
|
||||
/// Keeps track of a stored message.
|
||||
struct msg {
|
||||
/// Pointer to the next message on queue.
|
||||
struct msg *msg_next;
|
||||
/// The type of message.
|
||||
long msg_type;
|
||||
/// Pointer to the beginning of the message.
|
||||
char *msg_ptr;
|
||||
/// The length of the message.
|
||||
size_t msg_size;
|
||||
};
|
||||
|
||||
/// @brief Message queue data structure.
|
||||
struct msqid_ds {
|
||||
/// Ownership and permissions.
|
||||
struct ipc_perm msg_perm;
|
||||
/// Time of last msgsnd(2).
|
||||
time_t msg_stime;
|
||||
/// Time of last msgrcv(2).
|
||||
time_t msg_rtime;
|
||||
/// Time of creation or last modification by msgctl().
|
||||
time_t msg_ctime;
|
||||
/// Number of bytes in queue.
|
||||
unsigned short msg_cbytes;
|
||||
/// Number of messages in queue.
|
||||
unsigned short msg_qnum;
|
||||
/// Maximum number of bytes in queue.
|
||||
unsigned short msg_qbytes;
|
||||
/// PID of last msgsnd(2).
|
||||
pid_t msg_lspid;
|
||||
/// PID of last msgrcv(2).
|
||||
pid_t msg_lrpid;
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/// @brief Initializes the message queue system.
|
||||
/// @return 0 on success, 1 on failure.
|
||||
int msq_init(void);
|
||||
|
||||
/// @brief Get a System V message queue identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created message queue, or to create a new set.
|
||||
/// @param msgflg controls the behaviour of the function.
|
||||
/// @return the message queue identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
int sys_msgget(key_t key, int msgflg);
|
||||
|
||||
/// @brief Used to send messages.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param msgp points to a used-defined msgbuf.
|
||||
/// @param msgsz specifies the size in bytes of mtext.
|
||||
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
|
||||
|
||||
/// @brief Used to receive messages.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param msgp points to a used-defined msgbuf.
|
||||
/// @param msgsz specifies the size in bytes of mtext.
|
||||
/// @param msgtyp specifies the type of message requested, as follows:
|
||||
/// - msgtyp == 0: the first message on the queue is received.
|
||||
/// - msgtyp > 0: the first message of type, msgtyp, is received.
|
||||
/// - msgtyp < 0: the first message of the lowest type that is less than or
|
||||
/// equal to the absolute value of msgtyp is received.
|
||||
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||
/// @return the number of bytes actually copied on success, -1 on failure and
|
||||
/// errno is set to indicate the error.
|
||||
ssize_t sys_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||
|
||||
/// @brief Message queue control operations.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param cmd The command to perform.
|
||||
/// @param buf used with IPC_STAT and IPC_SET.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int sys_msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
||||
|
||||
#else
|
||||
|
||||
/// @brief Get a System V message queue identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created message queue, or to create a new set.
|
||||
/// @param msgflg controls the behaviour of the function.
|
||||
/// @return the message queue identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
int msgget(key_t key, int msgflg);
|
||||
|
||||
/// @brief Used to send messages.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param msgp points to a used-defined msgbuf.
|
||||
/// @param msgsz specifies the size in bytes of mtext.
|
||||
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
|
||||
|
||||
/// @brief Used to receive messages.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param msgp points to a used-defined msgbuf.
|
||||
/// @param msgsz specifies the size in bytes of mtext.
|
||||
/// @param msgtyp specifies the type of message requested, as follows:
|
||||
/// - msgtyp == 0: the first message on the queue is received.
|
||||
/// - msgtyp > 0: the first message of type, msgtyp, is received.
|
||||
/// - msgtyp < 0: the first message of the lowest type that is less than or
|
||||
/// equal to the absolute value of msgtyp is received.
|
||||
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||
/// @return the number of bytes actually copied on success, -1 on failure and
|
||||
/// errno is set to indicate the error.
|
||||
ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||
|
||||
/// @brief Message queue control operations.
|
||||
/// @param msqid the message queue identifier.
|
||||
/// @param cmd The command to perform.
|
||||
/// @param buf used with IPC_STAT and IPC_SET.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/// @file reboot.h
|
||||
/// @brief Defines the values required to issue a reboot.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Magic values required to use _reboot() system call.
|
||||
#define LINUX_REBOOT_MAGIC1 0xfee1dead
|
||||
/// Magic values required to use _reboot() system call.
|
||||
#define LINUX_REBOOT_MAGIC2 672274793
|
||||
/// Magic values required to use _reboot() system call.
|
||||
#define LINUX_REBOOT_MAGIC2A 85072278
|
||||
/// Magic values required to use _reboot() system call.
|
||||
#define LINUX_REBOOT_MAGIC2B 369367448
|
||||
/// Magic values required to use _reboot() system call.
|
||||
#define LINUX_REBOOT_MAGIC2C 537993216
|
||||
|
||||
// Commands accepted by the _reboot() system call.
|
||||
/// Restart system using default command and mode.
|
||||
#define LINUX_REBOOT_CMD_RESTART 0x01234567
|
||||
/// Stop OS and give system control to ROM monitor, if any.
|
||||
#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
|
||||
/// Ctrl-Alt-Del sequence causes RESTART command.
|
||||
#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
|
||||
/// Ctrl-Alt-Del sequence sends SIGINT to init task.
|
||||
#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
|
||||
/// Stop OS and remove all power from system, if possible.
|
||||
#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
|
||||
/// Restart system using given command string.
|
||||
#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
|
||||
/// Suspend system using software suspend if compiled in.
|
||||
#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
|
||||
/// Restart system using a previously loaded Linux kernel
|
||||
#define LINUX_REBOOT_CMD_KEXEC 0x45584543
|
||||
@@ -0,0 +1,135 @@
|
||||
/// @file sem.h
|
||||
/// @brief Definition of structure for managing semaphores.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "stddef.h"
|
||||
#include "sys/ipc.h"
|
||||
#include "time.h"
|
||||
|
||||
#define SEM_UNDO 0x1000 ///< Undo the operation on exit.
|
||||
|
||||
/// @defgroup SemaphoreCommands semctl commands
|
||||
/// @brief List of commands for semctl function.
|
||||
/// @{
|
||||
|
||||
#define GETPID 11 ///< Get sempid.
|
||||
#define GETVAL 12 ///< Get semval.
|
||||
#define GETALL 13 ///< Get all semval's.
|
||||
#define GETNCNT 14 ///< Get semncnt.
|
||||
#define GETZCNT 15 ///< Get semzcnt.
|
||||
#define SETVAL 16 ///< Set semval.
|
||||
#define SETALL 17 ///< Set all semval's.
|
||||
#define SEM_STAT 18 ///< Return a semid_ds structure.
|
||||
#define SEM_INFO 19 ///< Return a seminfo structure.
|
||||
|
||||
/// }@
|
||||
|
||||
#define SEM_SET_MAX 256
|
||||
|
||||
/// @brief Optional argument for semctl() function
|
||||
union semun {
|
||||
/// @brief Value for SETVAL.
|
||||
int val;
|
||||
/// @brief Buffer for IPC_STAT & IPC_SET.
|
||||
struct semid_ds *buf;
|
||||
/// @brief Array for GETALL & SETALL.
|
||||
unsigned short *array;
|
||||
/// @brief Buffer for IPC_INFO.
|
||||
struct seminfo *__buf;
|
||||
};
|
||||
|
||||
/// @brief Single Semaphore.
|
||||
struct sem {
|
||||
/// @brief Process ID of the last operation.
|
||||
pid_t sem_pid;
|
||||
/// @brief Semaphore Value.
|
||||
unsigned short sem_val;
|
||||
/// @brief Number of processes waiting for the semaphore.
|
||||
unsigned short sem_ncnt;
|
||||
/// @brief Number of processes waiting for the value to become 0.
|
||||
unsigned short sem_zcnt;
|
||||
};
|
||||
|
||||
/// @brief Semaphore set
|
||||
struct semid_ds {
|
||||
/// @brief Ownership and permissions.
|
||||
struct ipc_perm sem_perm;
|
||||
/// @brief Last semop time.
|
||||
time_t sem_otime;
|
||||
/// @brief Last change time.
|
||||
time_t sem_ctime;
|
||||
/// @brief Number of semaphores in set.
|
||||
unsigned short sem_nsems;
|
||||
};
|
||||
|
||||
/// @brief Buffer to use with the semaphore IPC.
|
||||
struct sembuf {
|
||||
/// @brief Semaphore index in array.
|
||||
unsigned short sem_num;
|
||||
/// @brief Semaphore operation.
|
||||
short sem_op;
|
||||
/// @brief Operation flags.
|
||||
short sem_flg;
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/// @brief Initializes the semaphore system.
|
||||
/// @return 0 on success, 1 on failure.
|
||||
int sem_init(void);
|
||||
|
||||
/// @brief Get a System V semaphore set identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created semaphore set, or to create a new set.
|
||||
/// @param nsems number of semaphores.
|
||||
/// @param semflg controls the behaviour of the function.
|
||||
/// @return the semaphore set identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
long sys_semget(key_t key, int nsems, int semflg);
|
||||
|
||||
/// @brief Performs operations on selected semaphores in the set.
|
||||
/// @param semid the semaphore set identifier.
|
||||
/// @param sops specifies operations to be performed on single semaphores.
|
||||
/// @param nsops number of operations.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long sys_semop(int semid, struct sembuf *sops, unsigned nsops);
|
||||
|
||||
/// @brief Performs control operations on a semaphore set.
|
||||
/// @param semid the semaphore set identifier.
|
||||
/// @param semnum the n-th semaphore of the set on which we perform the operations.
|
||||
/// @param cmd the command to perform.
|
||||
/// @param arg
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long sys_semctl(int semid, int semnum, int cmd, union semun *arg);
|
||||
|
||||
#else
|
||||
|
||||
/// @brief Get a System V semaphore set identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created semaphore set, or to create a new set.
|
||||
/// @param nsems number of semaphores.
|
||||
/// @param semflg controls the behaviour of the function.
|
||||
/// @return the semaphore set identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
long semget(key_t key, int nsems, int semflg);
|
||||
|
||||
/// @brief Performs operations on selected semaphores in the set.
|
||||
/// @param semid the semaphore set identifier.
|
||||
/// @param sops specifies operations to be performed on single semaphores.
|
||||
/// @param nsops number of operations.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long semop(int semid, struct sembuf *sops, unsigned nsops);
|
||||
|
||||
/// @brief Performs control operations on a semaphore set.
|
||||
/// @param semid the semaphore set identifier.
|
||||
/// @param semnum the n-th semaphore of the set on which we perform the operations.
|
||||
/// @param cmd the command to perform.
|
||||
/// @param arg
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long semctl(int semid, int semnum, int cmd, union semun *arg);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,163 @@
|
||||
/// @file shm.h
|
||||
/// @brief Definition of structure for managing shared memories.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "stddef.h"
|
||||
#include "sys/ipc.h"
|
||||
#include "time.h"
|
||||
|
||||
/// Data type for storing the number of attaches.
|
||||
typedef unsigned long shmatt_t;
|
||||
|
||||
/// @brief Shared memory data structure.
|
||||
struct shmid_ds {
|
||||
/// Operation permission struct.
|
||||
struct ipc_perm shm_perm;
|
||||
/// Size of segment in bytes.
|
||||
size_t shm_segsz;
|
||||
/// Time of last attach.
|
||||
time_t shm_atime;
|
||||
/// Time of last detach.
|
||||
time_t shm_dtime;
|
||||
/// Time of last change.
|
||||
time_t shm_ctime;
|
||||
/// Pid of creator.
|
||||
pid_t shm_cpid;
|
||||
/// Pid of last operator.
|
||||
pid_t shm_lpid;
|
||||
/// Number of current attaches.
|
||||
shmatt_t shm_nattch;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
#include "debug.h"
|
||||
#include "time.h"
|
||||
#include "kheap.h"
|
||||
#include "stddef.h"
|
||||
#include "paging.h"
|
||||
#include "syscall.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
//======== Permission flag for shmget ==========================================
|
||||
// or S_IRUGO from <linux/stat.h>.
|
||||
#define SHM_R 0400
|
||||
|
||||
// or S_IWUGO from <linux/stat.h>.
|
||||
#define SHM_W 0200
|
||||
//==============================================================================
|
||||
|
||||
//======== Commands for shmctl =================================================
|
||||
// Lock segment (root only).
|
||||
#define SHM_LOCK 11
|
||||
|
||||
// Unlock segment (root only).
|
||||
#define SHM_UNLOCK 12
|
||||
//==============================================================================
|
||||
|
||||
// Ipcs ctl commands.
|
||||
#define SHM_STAT 13
|
||||
|
||||
#define SHM_INFO 14
|
||||
|
||||
#define SHM_STAT_ANY 15
|
||||
|
||||
//======== shm_mode upper byte flags ===========================================
|
||||
// segment will be destroyed on last detach.
|
||||
#define SHM_DEST 01000
|
||||
|
||||
// Segment will not be swapped.
|
||||
#define SHM_LOCKED 02000
|
||||
|
||||
// Segment is mapped via hugetlb.
|
||||
#define SHM_HUGETLB 04000
|
||||
|
||||
// Don't check for reservations.
|
||||
#define SHM_NORESERVE 010000
|
||||
|
||||
#endif
|
||||
|
||||
#define SHM_RDONLY 010000 ///< Attach read-only else read-write.
|
||||
#define SHM_RND 020000 ///< Round attach address to SHMLBA.
|
||||
#define SHM_REMAP 040000 ///< Take-over region on attach.
|
||||
#define SHM_EXEC 0100000 ///< Execution access.
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/// @brief Initializes the shared memory.
|
||||
/// @return 0 on success, 1 on failure.
|
||||
int shm_init(void);
|
||||
|
||||
/// @brief Get a System V shared memory identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created shared memory, or to create a new one.
|
||||
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
|
||||
/// @param shmflg controls the behaviour of the function.
|
||||
/// @return the shared memory identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
long sys_shmget(key_t key, size_t size, int shmflg);
|
||||
|
||||
/// @brief Attaches the shared memory segment identified by shmid to the address
|
||||
/// space of the calling process.
|
||||
/// @param shmid the shared memory identifier.
|
||||
/// @param shmaddr the attaching address.
|
||||
/// @param shmflg controls the behaviour of the function.
|
||||
/// @return returns the address of the attached shared memory segment; on error
|
||||
/// (void *) -1 is returned, and errno is set to indicate the error.
|
||||
void *sys_shmat(int shmid, const void *shmaddr, int shmflg);
|
||||
|
||||
/// @brief Detaches the shared memory segment located at the address specified
|
||||
/// by shmaddr from the address space of the calling process
|
||||
/// @param shmaddr the address of the shared memory segment.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long sys_shmdt(const void *shmaddr);
|
||||
|
||||
/// @brief Performs the control operation specified by cmd on the shared memory
|
||||
/// segment whose identifier is given in shmid.
|
||||
/// @param shmid the shared memory identifier.
|
||||
/// @param cmd the command to perform.
|
||||
/// @param buf is a pointer to a shmid_ds structure.
|
||||
/// @return a non-negative value basedon on the requested operation, -1 on
|
||||
/// failure and errno is set to indicate the error.
|
||||
long sys_shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
||||
|
||||
#else
|
||||
|
||||
/// @brief Get a System V shared memory identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created shared memory, or to create a new one.
|
||||
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
|
||||
/// @param shmflg controls the behaviour of the function.
|
||||
/// @return the shared memory identifier, -1 on failure, and errno is set to
|
||||
/// indicate the error.
|
||||
long shmget(key_t key, size_t size, int shmflg);
|
||||
|
||||
/// @brief Attaches the shared memory segment identified by shmid to the address
|
||||
/// space of the calling process.
|
||||
/// @param shmid the shared memory identifier.
|
||||
/// @param shmaddr the attaching address.
|
||||
/// @param shmflg controls the behaviour of the function.
|
||||
/// @return returns the address of the attached shared memory segment; on error
|
||||
/// (void *) -1 is returned, and errno is set to indicate the error.
|
||||
void *shmat(int shmid, const void *shmaddr, int shmflg);
|
||||
|
||||
/// @brief Detaches the shared memory segment located at the address specified
|
||||
/// by shmaddr from the address space of the calling process
|
||||
/// @param shmaddr the address of the shared memory segment.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long shmdt(const void *shmaddr);
|
||||
|
||||
/// @brief Performs the control operation specified by cmd on the shared memory
|
||||
/// segment whose identifier is given in shmid.
|
||||
/// @param shmid the shared memory identifier.
|
||||
/// @param cmd the command to perform.
|
||||
/// @param buf is a pointer to a shmid_ds structure.
|
||||
/// @return a non-negative value basedon on the requested operation, -1 on
|
||||
/// failure and errno is set to indicate the error.
|
||||
long shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/// @file stat.h
|
||||
/// @brief Stat functions.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
#define __SYS_STAT_H
|
||||
|
||||
#include "bits/stat.h"
|
||||
#include "stddef.h"
|
||||
#include "time.h"
|
||||
|
||||
/// @brief Retrieves information about the file at the given location.
|
||||
/// @param path The path to the file that is being inquired.
|
||||
/// @param buf A structure where data about the file will be stored.
|
||||
/// @return Returns a negative value on failure.
|
||||
int stat(const char *path, stat_t *buf);
|
||||
|
||||
/// @brief Retrieves information about the file at the given location.
|
||||
/// @param fd The file descriptor of the file that is being inquired.
|
||||
/// @param buf A structure where data about the file will be stored.
|
||||
/// @return Returns a negative value on failure.
|
||||
int fstat(int fd, stat_t *buf);
|
||||
|
||||
/// @brief Creates a new directory at the given path.
|
||||
/// @param path The path of the new directory.
|
||||
/// @param mode The permission of the new directory.
|
||||
/// @return Returns a negative value on failure.
|
||||
int mkdir(const char *path, mode_t mode);
|
||||
|
||||
/// @brief Removes the given directory.
|
||||
/// @param path The path to the directory to remove.
|
||||
/// @return Returns a negative value on failure.
|
||||
int rmdir(const char *path);
|
||||
|
||||
/// @brief Creates a new file or rewrite an existing one.
|
||||
/// @param path path to the file.
|
||||
/// @param mode mode for file creation.
|
||||
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
|
||||
/// @details
|
||||
/// It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
|
||||
int creat(const char *path, mode_t mode);
|
||||
@@ -0,0 +1,69 @@
|
||||
/// @file types.h
|
||||
/// @brief Collection of Kernel datatype
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// The type of process id.
|
||||
typedef signed int pid_t;
|
||||
|
||||
/// The type of process user variable.
|
||||
typedef unsigned int user_t;
|
||||
|
||||
/// The type of process status.
|
||||
typedef unsigned int status_t;
|
||||
|
||||
/// Type for system keys.
|
||||
typedef int key_t;
|
||||
|
||||
/// Defines the list of flags of a process.
|
||||
typedef enum eflags_list {
|
||||
/// Carry flag.
|
||||
EFLAG_CF = (1 << 0),
|
||||
|
||||
/// Parity flag.
|
||||
EFLAG_PF = (1 << 2),
|
||||
|
||||
/// Auxiliary carry flag.
|
||||
EFLAG_AF = (1 << 4),
|
||||
|
||||
/// Zero flag.
|
||||
EFLAG_ZF = (1 << 6),
|
||||
|
||||
/// Sign flag.
|
||||
EFLAG_SF = (1 << 7),
|
||||
|
||||
/// Trap flag.
|
||||
EFLAG_TF = (1 << 8),
|
||||
|
||||
/// Interrupt enable flag.
|
||||
EFLAG_IF = (1 << 9),
|
||||
|
||||
/// Direction flag.
|
||||
EFLAG_DF = (1 << 10),
|
||||
|
||||
/// Overflow flag.
|
||||
EFLAG_OF = (1 << 11),
|
||||
|
||||
/// Nested task flag.
|
||||
EFLAG_NT = (1 << 14),
|
||||
|
||||
/// Resume flag.
|
||||
EFLAG_RF = (1 << 16),
|
||||
|
||||
/// Virtual 8086 mode flag.
|
||||
EFLAG_VM = (1 << 17),
|
||||
|
||||
/// Alignment check flag (486+).
|
||||
EFLAG_AC = (1 << 18),
|
||||
|
||||
/// Virutal interrupt flag.
|
||||
EFLAG_VIF = (1 << 19),
|
||||
|
||||
/// Virtual interrupt pending flag.
|
||||
EFLAG_VIP = (1 << 20),
|
||||
|
||||
/// ID flag.
|
||||
EFLAG_ID = (1 << 21),
|
||||
} eflags_list;
|
||||
@@ -0,0 +1,262 @@
|
||||
/// @file unistd.h
|
||||
/// @brief Functions used to manage files.
|
||||
/// @copyright (c) 2014-2024 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "stddef.h"
|
||||
#include "sys/dirent.h"
|
||||
|
||||
#define STDIN_FILENO 0 ///< Standard input.
|
||||
#define STDOUT_FILENO 1 ///< Standard output.
|
||||
#define STDERR_FILENO 2 ///< Standard error output.
|
||||
|
||||
/// @brief Read data from a file descriptor.
|
||||
/// @param fd The file descriptor.
|
||||
/// @param buf The buffer.
|
||||
/// @param nbytes The number of bytes to read.
|
||||
/// @return The number of read characters.
|
||||
ssize_t read(int fd, void *buf, size_t nbytes);
|
||||
|
||||
/// @brief Write data into a file descriptor.
|
||||
/// @param fd The file descriptor.
|
||||
/// @param buf The buffer collecting data to written.
|
||||
/// @param nbytes The number of bytes to write.
|
||||
/// @return The number of written bytes.
|
||||
ssize_t write(int fd, const void *buf, size_t nbytes);
|
||||
|
||||
/// @brief Opens the file specified by pathname.
|
||||
/// @param pathname A pathname for a file.
|
||||
/// @param flags file status flags and file access modes of the open file description.
|
||||
/// @param mode the file mode bits be applied when a new file is created.
|
||||
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
|
||||
int open(const char *pathname, int flags, mode_t mode);
|
||||
|
||||
/// @brief Close a file descriptor.
|
||||
/// @param fd The file descriptor.
|
||||
/// @return The result of the operation.
|
||||
int close(int fd);
|
||||
|
||||
/// @brief Repositions the file offset inside a file.
|
||||
/// @param fd The file descriptor of the file.
|
||||
/// @param offset The offest to use for the operation.
|
||||
/// @param whence The type of operation.
|
||||
/// @return Upon successful completion, returns the resulting offset
|
||||
/// location as measured in bytes from the beginning of the file. On
|
||||
/// error, the value (off_t) -1 is returned and errno is set to
|
||||
/// indicate the error.
|
||||
off_t lseek(int fd, off_t offset, int whence);
|
||||
|
||||
/// @brief Delete a name and possibly the file it refers to.
|
||||
/// @param path The path to the file.
|
||||
/// @return
|
||||
int unlink(const char *path);
|
||||
|
||||
/// @brief Creates a symbolic link.
|
||||
/// @param linkname the name of the link.
|
||||
/// @param path the entity it is linking to.
|
||||
/// @return 0 on success, a negative number if fails and errno is set.
|
||||
int symlink(const char *linkname, const char *path);
|
||||
|
||||
/// @brief Read the symbolic link, if present.
|
||||
/// @param file the file for which we want to read the symbolic link information.
|
||||
/// @param buffer the buffer where we will store the symbolic link path.
|
||||
/// @param bufsize the size of the buffer.
|
||||
/// @return The number of read characters on success, -1 otherwise and errno is set to indicate the error.
|
||||
int readlink(const char *path, char *buffer, size_t bufsize);
|
||||
|
||||
/// @brief Wrapper for exit system call.
|
||||
/// @param status The exit status.
|
||||
extern void exit(int status);
|
||||
|
||||
/// @brief Returns the process ID (PID) of the calling process.
|
||||
/// @return pid_t process identifier.
|
||||
extern pid_t getpid(void);
|
||||
|
||||
///@brief Return session id of the given process.
|
||||
/// If pid == 0 return the SID of the calling process
|
||||
/// If pid != 0 return the SID corresponding to the process having identifier == pid
|
||||
///@param pid process identifier from wich we want the SID
|
||||
///@return On success return SID of the session
|
||||
/// Otherwise return -1 with errno set on: EPERM or ESRCH
|
||||
extern pid_t getsid(pid_t pid);
|
||||
|
||||
///@brief creates a new session if the calling process is not a
|
||||
/// process group leader. The calling process is the leader of the
|
||||
/// new session (i.e., its session ID is made the same as its process
|
||||
/// ID). The calling process also becomes the process group leader
|
||||
/// of a new process group in the session (i.e., its process group ID
|
||||
/// is made the same as its process ID).
|
||||
///@return On success return SID of the session just created
|
||||
/// Otherwise return -1 with errno : EPERM
|
||||
extern pid_t setsid(void);
|
||||
|
||||
///@brief returns the Process Group ID (PGID) of the process specified by pid.
|
||||
/// If pid is zero, the process ID of the calling process is used.
|
||||
/// @param pid process of which we want to know the PGID.
|
||||
/// @return the PGID of the specified process.
|
||||
pid_t getpgid(pid_t pid);
|
||||
|
||||
/// @brief Sets the Process Group ID (PGID) of the process specified by pid.
|
||||
/// If pid is zero, the process ID of the calling process is used.
|
||||
/// @param pid process of which we want to set the PGID.
|
||||
/// @param pgid the PGID we want to set.
|
||||
/// @return returns zero. On error, -1 is returned, and errno is set appropriately.
|
||||
int setpgid(pid_t pid, pid_t pgid);
|
||||
|
||||
///@brief returns the group ID of the calling process.
|
||||
///@return GID of the current process
|
||||
extern pid_t getgid(void);
|
||||
|
||||
///@brief sets the effective group ID of the calling process.
|
||||
///@param pid process identifier to
|
||||
///@return On success, zero is returned.
|
||||
/// Otherwise returns -1 with errno set to :EINVAL or EPERM
|
||||
extern int setgid(pid_t pid);
|
||||
|
||||
///@brief Returns the User ID of the calling process.
|
||||
///@return User ID of the current process.
|
||||
extern uid_t getuid(void);
|
||||
|
||||
///@brief Sets the effective User ID of the calling process.
|
||||
///@param uid the new User ID.
|
||||
///@return On success, zero is returned.
|
||||
/// Otherwise returns -1 with errno set to :EINVAL or EPERM
|
||||
extern int setuid(uid_t uid);
|
||||
|
||||
/// @brief Returns the parent process ID (PPID) of the calling process.
|
||||
/// @return pid_t parent process identifier.
|
||||
extern pid_t getppid(void);
|
||||
|
||||
/// @brief Clone the calling process, but without copying the whole address space.
|
||||
/// The calling process is suspended until the new process exits or is
|
||||
/// replaced by a call to `execve'.
|
||||
/// @return Return -1 for errors, 0 to the new process, and the process ID of
|
||||
/// the new process to the old process.
|
||||
extern pid_t fork(void);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument list).
|
||||
/// @param path The absolute path to the binary file to execute.
|
||||
/// @param arg A list of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param ... The argument list.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execl(const char *path, const char *arg, ...);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument list).
|
||||
/// @param file The name of the binary file to execute, which is searched inside the
|
||||
/// paths specified inside the PATH environmental variable.
|
||||
/// @param arg A list of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param ... The argument list.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execlp(const char *file, const char *arg, ...);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument list).
|
||||
/// @param path The absolute path to the binary file to execute.
|
||||
/// @param arg A list of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param ... The argument list which contains as last argument the environment.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execle(const char *path, const char *arg, ...);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument list).
|
||||
/// @param file The name of the binary file to execute, which is searched inside the
|
||||
/// paths specified inside the PATH environmental variable.
|
||||
/// @param arg A list of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param ... The argument list which contains as last argument the environment.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execlpe(const char *file, const char *arg, ...);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument vector).
|
||||
/// @param path The absolute path to the binary file to execute.
|
||||
/// @param argv A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execv(const char *path, char *const argv[]);
|
||||
|
||||
/// @brief Replaces the current process image with a new process image (argument vector).
|
||||
/// @param file The name of the binary file to execute, which is searched inside the
|
||||
/// paths specified inside the PATH environmental variable.
|
||||
/// @param argv A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execvp(const char *file, char *const argv[]);
|
||||
|
||||
/// @brief Replaces the current process image with a new process
|
||||
/// image (argument vector), allows the caller to specify
|
||||
/// the environment of the executed program via `envp`.
|
||||
/// @param path The absolute path to the binary file to execute.
|
||||
/// @param argv A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param envp A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the environment list available to the executed program.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execve(const char *path, char *const argv[], char *const envp[]);
|
||||
|
||||
/// @brief Replaces the current process image with a new process
|
||||
/// image (argument vector), allows the caller to specify
|
||||
/// the environment of the executed program via `envp`.
|
||||
/// @param file The name of the binary file to execute, which is searched inside the
|
||||
/// paths specified inside the PATH environmental variable.
|
||||
/// @param argv A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the argument list available to the executed program.
|
||||
/// @param envp A vector of one or more pointers to null-terminated strings that represent
|
||||
/// the environment list available to the executed program.
|
||||
/// @return Returns -1 only if an error has occurred, and sets errno.
|
||||
int execvpe(const char *file, char *const argv[], char *const envp[]);
|
||||
|
||||
/// @brief Adds inc to the nice value for the calling thread.
|
||||
/// @param inc The value to add to the nice.
|
||||
/// @return On success, the new nice value is returned. On error, -1 is
|
||||
/// returned, and errno is set appropriately.
|
||||
int nice(int inc);
|
||||
|
||||
/// @brief Reboots the system, or enables/disables the reboot keystroke.
|
||||
/// @param magic1 fails (with the error EINVAL) unless equals LINUX_REBOOT_MAGIC1.
|
||||
/// @param magic2 fails (with the error EINVAL) unless equals LINUX_REBOOT_MAGIC2.
|
||||
/// @param cmd The command to send to the reboot.
|
||||
/// @param arg Argument passed with some specific commands.
|
||||
/// @return For the values of cmd that stop or restart the system, a
|
||||
/// successful call to reboot() does not return. For the other cmd
|
||||
/// values, zero is returned on success. In all cases, -1 is
|
||||
/// returned on failure, and errno is set appropriately.
|
||||
int reboot(int magic1, int magic2, unsigned int cmd, void *arg);
|
||||
|
||||
/// @brief Get current working directory.
|
||||
/// @param buf The array where the CWD will be copied.
|
||||
/// @param size The size of the array.
|
||||
/// @return On success, returns the same pointer to buf.
|
||||
/// On failure, returnr NULL, and errno is set to indicate the error.
|
||||
char *getcwd(char *buf, size_t size);
|
||||
|
||||
/// @brief Changes the current working directory to the given path.
|
||||
/// @param path The new current working directory.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int chdir(char const *path);
|
||||
|
||||
/// @brief Is identical to chdir(), the only difference is that the
|
||||
/// directory is given as an open file descriptor.
|
||||
/// @param fd The file descriptor of the open directory.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
int fchdir(int fd);
|
||||
|
||||
/// Provide access to the directory entries.
|
||||
/// @param fd The fd pointing to the opened directory.
|
||||
/// @param dirp The buffer where de data should be placed.
|
||||
/// @param count The size of the buffer.
|
||||
/// @return On success, the number of bytes read is returned. On end of
|
||||
/// directory, 0 is returned. On error, -1 is returned, and errno is set
|
||||
/// appropriately.
|
||||
ssize_t getdents(int fd, dirent_t *dirp, unsigned int count);
|
||||
|
||||
/// @brief Send signal to calling thread after desired seconds.
|
||||
/// @param seconds the amount of seconds.
|
||||
/// @return If there is a previous alarm() request with time remaining, alarm()
|
||||
/// shall return a non-zero value that is the number of seconds until the
|
||||
/// previous request would have generated a SIGALRM signal. Otherwise, alarm()
|
||||
/// shall return 0.
|
||||
unsigned alarm(int seconds);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user