Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos
repos/zig-tools/package-lock.json
{ "name": "zig-tools", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zig-tools", "version": "0.0.1", "devDependencies": { "@types/mocha": "^10.0.6", "@types/node": "18.x", "@types/vscode": "^1.87.0", "@typescript-eslint/eslint-plugin": "^7.4.0", "@typescript-eslint/parser": "^7.4.0", "@vscode/test-cli": "^0.0.8", "@vscode/test-electron": "^2.3.9", "eslint": "^8.57.0", "typescript": "^5.3.3" }, "engines": { "vscode": "^1.87.0" } }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, "dependencies": { "eslint-visitor-keys": "^3.3.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "node_modules/@eslint-community/regexpp": { "version": "4.10.0", "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/@eslint/eslintrc/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/@eslint/js": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^2.0.2", "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, "engines": { "node": ">=12.22" }, "funding": { "type": "github", "url": "https://github.com/sponsors/nzakas" } }, "node_modules/@humanwhocodes/object-schema": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dev": true, "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" }, "engines": { "node": ">=12" } }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.25", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" }, "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" }, "engines": { "node": ">= 8" } }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", "dev": true, "optional": true, "engines": { "node": ">=14" } }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true, "engines": { "node": ">= 6" } }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", "dev": true }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, "node_modules/@types/mocha": { "version": "10.0.6", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", "dev": true }, "node_modules/@types/node": { "version": "18.19.26", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.26.tgz", "integrity": "sha512-+wiMJsIwLOYCvUqSdKTrfkS8mpTp+MPINe6+Np4TAGFWWRWiBQ5kSq9nZGCSPkzx9mvT+uEukzpX4MOSCydcvw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, "node_modules/@types/vscode": { "version": "1.87.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.87.0.tgz", "integrity": "sha512-y3yYJV2esWr8LNjp3VNbSMWG7Y43jC8pCldG8YwiHGAQbsymkkMMt0aDT1xZIOFM2eFcNiUc+dJMx1+Z0UT8fg==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", "@typescript-eslint/scope-manager": "7.4.0", "@typescript-eslint/type-utils": "7.4.0", "@typescript-eslint/utils": "7.4.0", "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", "natural-compare": "^1.4.0", "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "@typescript-eslint/parser": "^7.0.0", "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/parser": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.4.0.tgz", "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", "dev": true, "dependencies": { "@typescript-eslint/scope-manager": "7.4.0", "@typescript-eslint/types": "7.4.0", "@typescript-eslint/typescript-estree": "7.4.0", "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/scope-manager": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.4.0", "@typescript-eslint/visitor-keys": "7.4.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@typescript-eslint/type-utils": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", "dev": true, "dependencies": { "@typescript-eslint/typescript-estree": "7.4.0", "@typescript-eslint/utils": "7.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/types": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.4.0.tgz", "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@typescript-eslint/typescript-estree": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.4.0", "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", "minimatch": "9.0.3", "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/utils": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.4.0.tgz", "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", "@typescript-eslint/scope-manager": "7.4.0", "@typescript-eslint/types": "7.4.0", "@typescript-eslint/typescript-estree": "7.4.0", "semver": "^7.5.4" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" } }, "node_modules/@typescript-eslint/visitor-keys": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.4.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, "node_modules/@vscode/test-cli": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/@vscode/test-cli/-/test-cli-0.0.8.tgz", "integrity": "sha512-sBSMSDzJChiiDjmys2Q6uI4SIoUYf0t6oDsQO3ypaQ7udha9YD4e2On9e9VE5OBayZMpxbgJX+NudmCwJMdOIg==", "dev": true, "dependencies": { "@types/mocha": "^10.0.2", "c8": "^9.1.0", "chokidar": "^3.5.3", "enhanced-resolve": "^5.15.0", "glob": "^10.3.10", "minimatch": "^9.0.3", "mocha": "^10.2.0", "supports-color": "^9.4.0", "yargs": "^17.7.2" }, "bin": { "vscode-test": "out/bin.mjs" } }, "node_modules/@vscode/test-electron": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.9.tgz", "integrity": "sha512-z3eiChaCQXMqBnk2aHHSEkobmC2VRalFQN0ApOAtydL172zXGxTwGrRtviT5HnUB+Q+G3vtEYFtuQkYqBzYgMA==", "dev": true, "dependencies": { "http-proxy-agent": "^4.0.1", "https-proxy-agent": "^5.0.0", "jszip": "^3.10.1", "semver": "^7.5.2" }, "engines": { "node": ">=16" } }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" }, "engines": { "node": ">=0.4.0" } }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dev": true, "dependencies": { "debug": "4" }, "engines": { "node": ">= 6.0.0" } }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/epoberezkin" } }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { "color-convert": "^2.0.1" }, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" }, "engines": { "node": ">= 8" } }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "node_modules/binary-extensions": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "dev": true, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, "dependencies": { "fill-range": "^7.0.1" }, "engines": { "node": ">=8" } }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "node_modules/c8": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", "dev": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@istanbuljs/schema": "^0.1.3", "find-up": "^5.0.0", "foreground-child": "^3.1.1", "istanbul-lib-coverage": "^3.2.0", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.1.6", "test-exclude": "^6.0.0", "v8-to-istanbul": "^9.0.0", "yargs": "^17.7.2", "yargs-parser": "^21.1.1" }, "bin": { "c8": "bin/c8.js" }, "engines": { "node": ">=14.14.0" } }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/chalk/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dev": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "engines": { "node": ">= 8.10.0" }, "funding": { "url": "https://paulmillr.com/funding/" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" }, "engines": { "node": ">=12" } }, "node_modules/cliui/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/cliui/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/cliui/node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { "color-name": "~1.1.4" }, "engines": { "node": ">=7.0.0" } }, "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" }, "engines": { "node": ">= 8" } }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" }, "engines": { "node": ">=6.0" }, "peerDependenciesMeta": { "supports-color": { "optional": true } } }, "node_modules/decamelize": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true, "engines": { "node": ">=0.3.1" } }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, "dependencies": { "path-type": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "dependencies": { "esutils": "^2.0.2" }, "engines": { "node": ">=6.0.0" } }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, "node_modules/enhanced-resolve": { "version": "5.16.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.0.tgz", "integrity": "sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA==", "dev": true, "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" }, "engines": { "node": ">=10.13.0" } }, "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/eslint": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", "@eslint/js": "8.57.0", "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.2", "eslint-visitor-keys": "^3.4.3", "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3", "strip-ansi": "^6.0.1", "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "dependencies": { "is-glob": "^4.0.3" }, "engines": { "node": ">=10.13.0" } }, "node_modules/eslint/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/esquery": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" }, "engines": { "node": ">=0.10" } }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "dependencies": { "estraverse": "^5.2.0" }, "engines": { "node": ">=4.0" } }, "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "engines": { "node": ">=4.0" } }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" }, "engines": { "node": ">=8.6.0" } }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" } }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "dependencies": { "flat-cache": "^3.0.4" }, "engines": { "node": "^10.12.0 || >=12.0.0" } }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", "dev": true, "bin": { "flat": "cli.js" } }, "node_modules/flat-cache": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", "dev": true, "dependencies": { "flatted": "^3.2.9", "keyv": "^4.5.3", "rimraf": "^3.0.2" }, "engines": { "node": "^10.12.0 || >=12.0.0" } }, "node_modules/flatted": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, "node_modules/foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, "optional": true, "os": [ "darwin" ], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, "engines": { "node": "6.* || 8.* || >= 10.*" } }, "node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^2.3.6", "minimatch": "^9.0.1", "minipass": "^7.0.4", "path-scurry": "^1.10.2" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "dependencies": { "is-glob": "^4.0.1" }, "engines": { "node": ">= 6" } }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" }, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.2.9", "ignore": "^5.2.0", "merge2": "^1.4.1", "slash": "^3.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true, "bin": { "he": "bin/he" } }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, "node_modules/http-proxy-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", "dev": true, "dependencies": { "@tootallnate/once": "1", "agent-base": "6", "debug": "4" }, "engines": { "node": ">= 6" } }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "dependencies": { "agent-base": "6", "debug": "4" }, "engines": { "node": ">= 6" } }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" } }, "node_modules/immediate": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", "dev": true }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" }, "engines": { "node": ">=6" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "engines": { "node": ">=0.8.19" } }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, "dependencies": { "binary-extensions": "^2.0.0" }, "engines": { "node": ">=8" } }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "dependencies": { "is-extglob": "^2.1.1" }, "engines": { "node": ">=0.10.0" } }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, "engines": { "node": ">=0.12.0" } }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/istanbul-lib-coverage": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/istanbul-lib-report": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, "dependencies": { "istanbul-lib-coverage": "^3.0.0", "make-dir": "^4.0.0", "supports-color": "^7.1.0" }, "engines": { "node": ">=10" } }, "node_modules/istanbul-lib-report/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/istanbul-reports": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", "dev": true, "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/jszip": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", "dev": true, "dependencies": { "lie": "~3.3.0", "pako": "~1.0.2", "readable-stream": "~2.3.6", "setimmediate": "^1.0.5" } }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, "dependencies": { "json-buffer": "3.0.1" } }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/lie": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", "dev": true, "dependencies": { "immediate": "~3.0.5" } }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "dependencies": { "p-locate": "^5.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lru-cache": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "dev": true, "engines": { "node": "14 || >=16.14" } }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, "dependencies": { "semver": "^7.5.3" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, "engines": { "node": ">= 8" } }, "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" } }, "node_modules/minimatch": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minipass": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "dev": true, "engines": { "node": ">=16 || 14 >=14.17" } }, "node_modules/mocha": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" }, "bin": { "_mocha": "bin/_mocha", "mocha": "bin/mocha.js" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/mocha/node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "funding": [ { "type": "individual", "url": "https://paulmillr.com/funding/" } ], "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "engines": { "node": ">= 8.10.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^7.0.0" } }, "node_modules/mocha/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/mocha/node_modules/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", "once": "^1.3.0" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=10" } }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, "node_modules/mocha/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/supports-color?sponsor=1" } }, "node_modules/mocha/node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/mocha/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.0", "y18n": "^5.0.5", "yargs-parser": "^20.2.2" }, "engines": { "node": ">=10" } }, "node_modules/mocha/node_modules/yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", "dev": true, "engines": { "node": ">=10" } }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" } }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, "dependencies": { "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "dependencies": { "yocto-queue": "^0.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/p-locate": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "dependencies": { "p-limit": "^3.0.2" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "dev": true }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "dependencies": { "callsites": "^3.0.0" }, "engines": { "node": ">=6" } }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/path-scurry": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz", "integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==", "dev": true, "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, "engines": { "node": ">=8.6" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ] }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "dependencies": { "safe-buffer": "^5.1.0" } }, "node_modules/readable-stream": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "dev": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, "dependencies": { "picomatch": "^2.2.1" }, "engines": { "node": ">=8.10.0" } }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "engines": { "node": ">=4" } }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true, "engines": { "iojs": ">=1.0.0", "node": ">=0.10.0" } }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "dependencies": { "glob": "^7.1.3" }, "bin": { "rimraf": "bin.js" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/rimraf/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, "engines": { "node": "*" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ], "dependencies": { "queue-microtask": "^1.2.2" } }, "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "node_modules/semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" }, "bin": { "semver": "bin/semver.js" }, "engines": { "node": ">=10" } }, "node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=10" } }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", "dev": true, "dependencies": { "randombytes": "^2.1.0" } }, "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", "dev": true }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/string-width-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/string-width/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/string-width/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/supports-color": { "version": "9.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz", "integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/supports-color?sponsor=1" } }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", "dev": true, "dependencies": { "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", "minimatch": "^3.0.4" }, "engines": { "node": ">=8" } }, "node_modules/test-exclude/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/test-exclude/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, "engines": { "node": "*" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/test-exclude/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "dependencies": { "is-number": "^7.0.0" }, "engines": { "node": ">=8.0" } }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, "engines": { "node": ">=16" }, "peerDependencies": { "typescript": ">=4.2.0" } }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "dependencies": { "prelude-ls": "^1.2.1" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/typescript": { "version": "5.4.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { "node": ">=14.17" } }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "dependencies": { "punycode": "^2.1.0" } }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "node_modules/v8-to-istanbul": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^2.0.0" }, "engines": { "node": ">=10.12.0" } }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "bin/node-which" }, "engines": { "node": ">= 8" } }, "node_modules/workerpool": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/wrap-ansi-cjs/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/wrap-ansi/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, "engines": { "node": ">=10" } }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" }, "engines": { "node": ">=12" } }, "node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "engines": { "node": ">=12" } }, "node_modules/yargs-unparser": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, "dependencies": { "camelcase": "^6.0.0", "decamelize": "^4.0.0", "flat": "^5.0.2", "is-plain-obj": "^2.1.0" }, "engines": { "node": ">=10" } }, "node_modules/yargs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/yargs/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } } } }
0
repos
repos/zig-tools/tsconfig.json
{ "compilerOptions": { "module": "Node16", "target": "ES2022", "outDir": "out", "lib": [ "ES2022" ], "sourceMap": true, "rootDir": "src", "strict": true /* enable all strict type-checking options */ /* Additional Checks */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ } }
0
repos
repos/zig-tools/README.md
# Zig tools <p align="center"> <img src="images/readme_icon.png" width="300"> </p> <p align="center"> <a href="https://marketplace.visualstudio.com/items?itemName=bwork.zig-tools"><img alt="Visual Studio Marketplace Version" src="https://img.shields.io/visual-studio-marketplace/v/bwork.zig-tools?style=flat-square&logo=visualstudiocode&label=vscode&color=f7a41d"></a> </p> ## ⚡ Features ### Data type hints on hover ![screencast](images/demo1.gif) ### Bitwise operation hints on hover ![screencast](images/demo2.gif) ### Convert a number from hexadecimal to decimal ![screencast](images/demo3.gif)
0
repos/zig-tools
repos/zig-tools/src/extension.ts
// The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; import { TypesAutocomplete } from './tools/autocompletion'; import { BitwiseOperationHints } from './tools/bitwiseOpHint'; import { HexHints } from './tools/hexHints'; import { TypeHints } from './tools/typeHints'; const enum Config { TypeHints = "zig-tools.type hints", TypeAutocompletion = "zig-tools.type autocompletion", BitwiseOPHints = "zig-tools.bitwise operation hints", HexHints = "zig-tools.hex hints", } let hoverProviders: vscode.Disposable[] = []; let disposable: vscode.Disposable | undefined; export function activate(context: vscode.ExtensionContext) { initExtensions(); vscode.workspace.onDidChangeConfiguration(initExtensions); if (disposable) { context.subscriptions.push(disposable); } } function initExtensions() { const isThEnabled = <boolean>vscode.workspace.getConfiguration().get(Config.TypeHints); const isDtAutocompletionEnabled = <boolean>vscode.workspace.getConfiguration().get(Config.TypeAutocompletion); const isBitwiseOPHintsEnabled = <boolean>vscode.workspace.getConfiguration().get(Config.BitwiseOPHints); const isHexHintsEnabeld = <boolean>vscode.workspace.getConfiguration().get(Config.HexHints); hoverProviders.forEach(provider => provider.dispose()); hoverProviders = []; if (isHexHintsEnabeld) { hoverProviders.push( vscode.languages.registerHoverProvider({ language: "zig" }, HexHints) ); } if (isBitwiseOPHintsEnabled) { hoverProviders.push( vscode.languages.registerHoverProvider({ language: "zig" }, BitwiseOperationHints) ); } if (isThEnabled) { hoverProviders.push( vscode.languages.registerHoverProvider({ language: "zig" }, TypeHints) ); } if (isDtAutocompletionEnabled) { hoverProviders.push( vscode.languages.registerCompletionItemProvider({ language: "zig" }, TypesAutocomplete) ); } disposable = vscode.Disposable.from(...hoverProviders); }
0
repos/zig-tools/src
repos/zig-tools/src/tools/hexHints.ts
import * as vscode from 'vscode'; export const HexHints: vscode.HoverProvider = { provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) { const range = document.getWordRangeAtPosition(position); const hexStr = document.getText(range); if (hexStr.startsWith("0x")) { // hex string if (Number.isNaN(Number(hexStr))) { return; } return new vscode.Hover(`${Number(hexStr)}`); } } };
0
repos/zig-tools/src
repos/zig-tools/src/tools/autocompletion.ts
import * as vscode from 'vscode'; export const TypesAutocomplete: vscode.CompletionItemProvider = { provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) { const compItems: vscode.CompletionItem[] = []; // there is no autocompletion for these data types in zig extension (idk why lol) const dataTypes = [ "i8", "i16", "i32", "i64", "i28", // uint "u8", "u16", "u32", "u64", "u128", // float "f16", "f32", "f64", "f80", "f128", ]; dataTypes.forEach(dataType => { const item = new vscode.CompletionItem(dataType, vscode.CompletionItemKind.TypeParameter); compItems.push(item); }); return compItems; } };
0
repos/zig-tools/src
repos/zig-tools/src/tools/bitwiseOpHint.ts
import * as vscode from 'vscode'; export const BitwiseOperationHints: vscode.HoverProvider = { provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) { const lineText = document.lineAt(position.line).text; const wordRange = document.getWordRangeAtPosition(position, /<<?|\||&|\^|>>/); if (!wordRange) { return; } const operator = document.getText(wordRange); const { firstNum, secondNum } = getNumbersAroundOperator(lineText, wordRange); if (!firstNum || !secondNum) { return; } const result = execute(operator, firstNum, secondNum); const mdStr = new vscode.MarkdownString(); mdStr.appendCodeblock(`${firstNum} ${operator} ${secondNum}`); mdStr.appendMarkdown(`Result of bitwise operation: \`${result}\``); return new vscode.Hover(mdStr); }, }; function getNumbersAroundOperator(lineText: string, wordRange: vscode.Range): { firstNum: number | undefined, secondNum: number | undefined; } { const textBeforeOperator = lineText.substring(0, wordRange.start.character); const textAfterOperator = lineText.substring(wordRange.end.character); const firstNum = findFirstNum(textBeforeOperator); const secondNum = findSecondNum(textAfterOperator); return { firstNum, secondNum }; } function findFirstNum(text: string): number | undefined { const matches = text.match(/\d+/g); if (matches && matches.length > 0) { return parseInt(matches[matches.length - 1]); } return undefined; } function findSecondNum(text: string): number | undefined { const matches = text.match(/\d+/); if (matches && matches.length > 0) { return parseInt(matches[0]); } return undefined; } function execute(operator: string, firstNum: number, secondNum: number): number { switch (operator) { case "&": return firstNum & secondNum; case "^": return firstNum ^ secondNum; case "|": return firstNum | secondNum; case ">>": return firstNum >> secondNum; case "<<": return firstNum << secondNum; } return 0; }
0
repos/zig-tools/src
repos/zig-tools/src/tools/typeHints.ts
import * as vscode from 'vscode'; export const TypeHints: vscode.HoverProvider = { provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) { const range = document.getWordRangeAtPosition(position); const datatype = document.getText(range); const curLine = document.lineAt(position.line).text; if (['i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'isize', 'usize', 'comptime_int', 'comptime_float'].includes(datatype)) { const mdStr = new vscode.MarkdownString(); mdStr.appendCodeblock(curLine.trimStart(), 'zig'); switch (datatype) { // int case "i8": mdStr.appendText(`${datatype} is the set of all signed 8-bit integers.\nRange: -128 through 127.`); return new vscode.Hover(mdStr); case "i16": mdStr.appendText(`${datatype} is the set of all signed 16 - bit integers.\nRange: -32,768 through 32,767.`); return new vscode.Hover(mdStr); case "i32": mdStr.appendText(`${datatype} is the set of all signed 32-bit integers.\nRange: -2,147,483,648 through 2,147,483,647.`); return new vscode.Hover(mdStr); case "i64": mdStr.appendText(`${datatype} is the set of all signed 64-bit integers.\nRange: -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.`); return new vscode.Hover(mdStr); case "i128": mdStr.appendText(`${datatype} is the set of all signed 128-bit integers.\nRange: -170,141,183,460,469,231,731,687,303,715,884,105,728 through 170,141,183,460,469,231,731,687,303,715,884,105,727.`); return new vscode.Hover(mdStr); // uint case 'u8': mdStr.appendText(`${datatype} is the set of all unsigned 8-bit integers.\nRange: 0 through 255.`); return new vscode.Hover(mdStr); case 'u16': mdStr.appendText(`${datatype} is the set of all unsigned 16-bit integers.\nRange: 0 through 65,535.`); return new vscode.Hover(mdStr); case 'u32': mdStr.appendText(`${datatype} is the set of all unsigned 32-bit integers.\nRange: 0 through 4,294,967,295.`); return new vscode.Hover(mdStr); case 'u64': mdStr.appendText(`${datatype} is the set of all unsigned 64-bit integers.\nRange: 0 through 18,446,744,073,709,551,615.`); return new vscode.Hover(mdStr); case 'u64': mdStr.appendText(`${datatype} is the set of all unsigned 64-bit integers.\nRange: 0 through 18,446,744,073,709,551,615.`); return new vscode.Hover(mdStr); case 'u128': mdStr.appendText(`${datatype} is the set of all unsigned 128-bit integers.\nRange: 0 through 340,282,366,920,938,463,463,374,607,431,768,211,455.`); return new vscode.Hover(mdStr); // other case 'isize': mdStr.appendText(`${datatype} is the signed pointer sized integer.\nC Equivalent: intptr_t.`); return new vscode.Hover(mdStr); case 'usize': mdStr.appendMarkdown(`${datatype} is the unsigned pointer sized integer. Also see [#5185](https://github.com/ziglang/zig/issues/5185).\n\nC Equivalent: uintptr_t, size_t.`); return new vscode.Hover(mdStr); case "comptime_int": mdStr.appendMarkdown(`${datatype} only allowed for [comptime](https://ziglang.org/documentation/master/#comptime)-known values.\n\nThe type of integer literals.`); return new vscode.Hover(mdStr); case "comptime_float": mdStr.appendMarkdown(`${datatype} only allowed for [comptime](https://ziglang.org/documentation/master/#comptime)-known values.\n\nThe type of float literals.`); return new vscode.Hover(mdStr); } } return null; } };
0
repos
repos/wavefront-obj/wavefront-obj.zig
const std = @import("std"); const zlm = @import("zlm"); const log = std.log.scoped(.wavefront_obj); const vec2 = zlm.vec2; const vec3 = zlm.vec3; const vec4 = zlm.vec4; const Vec2 = zlm.Vec2; const Vec3 = zlm.Vec3; const Vec4 = zlm.Vec4; test "wavefront-obj" { std.testing.refAllDecls(@This()); } // this file parses OBJ wavefront according to // http://paulbourke.net/dataformats/obj/ // with a lot of restrictions pub const Vertex = struct { position: usize, normal: ?usize, textureCoordinate: ?usize, }; pub const Face = struct { vertices: []Vertex, }; pub const Line = struct { vertices: [2]Vertex, }; pub const Object = struct { name: []const u8, material: ?[]const u8, start: usize, count: usize, }; pub const Model = struct { const Self = @This(); allocator: std.mem.Allocator, arena: std.heap.ArenaAllocator, positions: []Vec4, normals: []Vec3, textureCoordinates: []Vec3, faces: []Face, lines: []Line, objects: []Object, pub fn deinit(self: *Self) void { self.allocator.free(self.positions); self.allocator.free(self.normals); self.allocator.free(self.textureCoordinates); self.allocator.free(self.faces); self.allocator.free(self.lines); self.allocator.free(self.objects); self.arena.deinit(); self.* = undefined; } }; fn parseVertexSpec(spec: []const u8) !Vertex { var vertex = Vertex{ .position = 0, .normal = null, .textureCoordinate = null, }; var iter = std.mem.split(u8, spec, "/"); var state: u32 = 0; while (iter.next()) |part| { switch (state) { 0 => vertex.position = (try std.fmt.parseInt(usize, part, 10)) - 1, 1 => vertex.textureCoordinate = if (!std.mem.eql(u8, part, "")) (try std.fmt.parseInt(usize, part, 10)) - 1 else null, 2 => vertex.normal = if (!std.mem.eql(u8, part, "")) (try std.fmt.parseInt(usize, part, 10)) - 1 else null, else => return error.InvalidFormat, } state += 1; } return vertex; } pub fn loadFile(allocator: std.mem.Allocator, path: []const u8) !Model { var file = try std.fs.cwd().openFile(path, .{ .mode = .read_only }); defer file.close(); return load(allocator, file.reader()); } pub fn load( allocator: std.mem.Allocator, stream: anytype, ) !Model { var arena = std.heap.ArenaAllocator.init(allocator); errdefer arena.deinit(); var positions = std.ArrayList(Vec4).init(allocator); defer positions.deinit(); var normals = std.ArrayList(Vec3).init(allocator); defer normals.deinit(); var textureCoordinates = std.ArrayList(Vec3).init(allocator); defer textureCoordinates.deinit(); var faces = std.ArrayList(Face).init(allocator); defer faces.deinit(); var lines = std.ArrayList(Line).init(allocator); defer lines.deinit(); var objects = std.ArrayList(Object).init(allocator); defer objects.deinit(); try positions.ensureTotalCapacity(10_000); try normals.ensureTotalCapacity(10_000); try textureCoordinates.ensureTotalCapacity(10_000); try faces.ensureTotalCapacity(10_000); try lines.ensureTotalCapacity(10_000); try objects.ensureTotalCapacity(100); // note: // this may look like a dangling pointer as ArrayList changes it's pointers when resized. // BUT: the pointer will be changed with the added element, so it will not dangle var current_object: ?*Object = null; var line_reader = lineIterator(allocator, stream); defer line_reader.deinit(); while (try line_reader.next()) |line| { errdefer { log.err("error parsing line: '{s}'", .{line}); } // parse vertex if (std.mem.startsWith(u8, line, "v ")) { var iter = std.mem.tokenize(u8, line[2..], " "); var state: u32 = 0; var vertex = vec4(0, 0, 0, 1); while (iter.next()) |part| { switch (state) { 0 => vertex.x = try std.fmt.parseFloat(f32, part), 1 => vertex.y = try std.fmt.parseFloat(f32, part), 2 => vertex.z = try std.fmt.parseFloat(f32, part), 3 => vertex.w = try std.fmt.parseFloat(f32, part), else => return error.InvalidFormat, } state += 1; } if (state < 3) // v x y z w, with x,y,z are required, w is optional return error.InvalidFormat; try positions.append(vertex); } // parse uv coords else if (std.mem.startsWith(u8, line, "vt ")) { var iter = std.mem.tokenize(u8, line[3..], " "); var state: u32 = 0; var texcoord = vec3(0, 0, 0); while (iter.next()) |part| { switch (state) { 0 => texcoord.x = try std.fmt.parseFloat(f32, part), 1 => texcoord.y = try std.fmt.parseFloat(f32, part), 2 => texcoord.z = try std.fmt.parseFloat(f32, part), else => return error.InvalidFormat, } state += 1; } if (state < 1) // vt u v w, with u is required, v and w are optional return error.InvalidFormat; try textureCoordinates.append(texcoord); } // parse normals else if (std.mem.startsWith(u8, line, "vn ")) { var iter = std.mem.tokenize(u8, line[3..], " "); var state: u32 = 0; var normal = vec3(0, 0, 0); while (iter.next()) |part| { switch (state) { 0 => normal.x = try std.fmt.parseFloat(f32, part), 1 => normal.y = try std.fmt.parseFloat(f32, part), 2 => normal.z = try std.fmt.parseFloat(f32, part), else => return error.InvalidFormat, } state += 1; } if (state < 3) // vn i j k, with i,j,k are required, none are optional return error.InvalidFormat; try normals.append(normal); } // parse faces else if (std.mem.startsWith(u8, line, "f ")) { var iter = std.mem.tokenize(u8, line[2..], " "); var state: u32 = 0; var vertices = std.ArrayList(Vertex).init(arena.allocator()); defer vertices.deinit(); while (iter.next()) |part| { const vert = try parseVertexSpec(part); try vertices.append(vert); state += 1; } if (vertices.items.len < 3) // less than 3 faces is an error (no line or point support) return error.InvalidFormat; try faces.append(Face{ .vertices = vertices.toOwnedSlice(), }); } // parse lines else if (std.mem.startsWith(u8, line, "l ")) { var iter = std.mem.tokenize(u8, line[2..], " "); var state: u32 = 0; var vertices = std.ArrayList(Vertex).init(arena.allocator()); defer vertices.deinit(); while (iter.next()) |part| { const vert = try parseVertexSpec(part); try vertices.append(vert); state += 1; } if (vertices.items.len != 2) // Each line is always 2 vertices. return error.InvalidFormat; try lines.append(Line{ .vertices = vertices.items[0..2].*, }); } // parse objects else if (std.mem.startsWith(u8, line, "o ")) { if (current_object) |obj| { // terminate object obj.count = faces.items.len - obj.start; } var obj = try objects.addOne(); obj.start = faces.items.len; obj.count = 0; obj.name = arena.allocator().dupe(u8, line[2..]) catch |err| { _ = objects.pop(); // remove last element, then error return err; }; current_object = obj; } // parse material libraries else if (std.mem.startsWith(u8, line, "mtllib ")) { // ignore material libraries for now... // TODO: Implement material libraries } // parse material application else if (std.mem.startsWith(u8, line, "usemtl ")) { if (current_object) |*obj| { if (obj.*.material != null) { // duplicate object when two materials per object const current_name = obj.*.name; // terminate object obj.*.count = faces.items.len - obj.*.start; obj.* = try objects.addOne(); obj.*.start = faces.items.len; obj.*.count = 0; obj.*.name = arena.allocator().dupe(u8, current_name) catch |err| { _ = objects.pop(); // remove last element, then error return err; }; } obj.*.material = try arena.allocator().dupe(u8, line[7..]); } else { current_object = try objects.addOne(); current_object.?.start = faces.items.len; current_object.?.count = 0; current_object.?.name = arena.allocator().dupe(u8, "unnamed") catch |err| { _ = objects.pop(); // remove last element, then error return err; }; current_object.?.material = try arena.allocator().dupe(u8, line[7..]); } } // parse smoothing groups else if (std.mem.startsWith(u8, line, "s ")) { // and just ignore them :( } else { log.warn("unrecognized line: {s}", .{line}); } } // terminate object if any if (current_object) |obj| { obj.count = faces.items.len - obj.start; } return Model{ .allocator = allocator, .arena = arena, .positions = positions.toOwnedSlice(), .normals = normals.toOwnedSlice(), .textureCoordinates = textureCoordinates.toOwnedSlice(), .faces = faces.toOwnedSlice(), .lines = lines.toOwnedSlice(), .objects = objects.toOwnedSlice(), }; } pub const Color = struct { r: f32, g: f32, b: f32, }; pub const Material = struct { ambient_texture: ?[]const u8 = null, diffuse_texture: ?[]const u8 = null, specular_texture: ?[]const u8 = null, ambient_color: ?Color = null, diffuse_color: ?Color = null, specular_color: ?Color = null, }; pub const MaterialLibrary = struct { const Self = @This(); arena: std.heap.ArenaAllocator, materials: std.StringHashMap(Material), pub fn deinit(self: *Self) void { self.materials.deinit(); self.arena.deinit(); self.* = undefined; } }; pub fn loadMaterials(allocator: *std.mem.Allocator, stream: anytype) !MaterialLibrary { var materials = std.StringHashMap(Material).init(allocator); errdefer materials.deinit(); var arena = std.heap.ArenaAllocator.init(allocator); errdefer arena.deinit(); var line_reader = lineIterator(allocator, stream); defer line_reader.deinit(); var current_mtl: ?*Material = null; while (try line_reader.next()) |line| { errdefer { log.err("error parsing line: '{s}'\n", .{ line, }); } if (std.mem.startsWith(u8, line, "newmtl ")) { const mtl_name = try arena.allocator.dupe(u8, line[7..]); const gop = try materials.getOrPut(mtl_name); if (gop.found_existing) { log.err("duplicate material name: '{s}'", .{mtl_name}); return error.DuplicateMaterial; } gop.entry.value = Material{}; current_mtl = &gop.entry.value; } else if (std.mem.startsWith(u8, line, "Ka ")) { if (current_mtl) |mtl| { mtl.ambient_color = try parseColor(line[3..]); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else if (std.mem.startsWith(u8, line, "Kd ")) { if (current_mtl) |mtl| { mtl.diffuse_color = try parseColor(line[3..]); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else if (std.mem.startsWith(u8, line, "Ks ")) { if (current_mtl) |mtl| { mtl.specular_color = try parseColor(line[3..]); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else if (std.mem.startsWith(u8, line, "map_Ka")) { if (current_mtl) |mtl| { mtl.ambient_texture = try arena.allocator.dupe(u8, std.mem.trim(u8, line[7..], " \t\r\n")); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else if (std.mem.startsWith(u8, line, "map_Kd")) { if (current_mtl) |mtl| { mtl.diffuse_texture = try arena.allocator.dupe(u8, std.mem.trim(u8, line[7..], " \t\r\n")); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else if (std.mem.startsWith(u8, line, "map_Ks")) { if (current_mtl) |mtl| { mtl.specular_texture = try arena.allocator.dupe(u8, std.mem.trim(u8, line[7..], " \t\r\n")); } else { log.err("missing newmtl!", .{}); return error.InvalidFormat; } } else { log.warn("unrecognized line: '{s}'", .{line}); } } return MaterialLibrary{ .arena = arena, .materials = materials, }; } fn parseColor(line: []const u8) !Color { var iterator = std.mem.tokenize(line, " "); var result = Color{ .r = undefined, .g = undefined, .b = undefined, }; var index: usize = 0; while (iterator.next()) |tok| : (index += 1) { switch (index) { 0 => result.r = try std.fmt.parseFloat(f32, tok), 1 => result.g = try std.fmt.parseFloat(f32, tok), 2 => result.b = try std.fmt.parseFloat(f32, tok), else => return error.InvalidFormat, } } if (index < 3) return error.InvalidFormat; return result; } fn LineIterator(comptime Reader: type) type { return struct { const Self = @This(); reader: Reader, buffer: std.ArrayList(u8), pub fn deinit(self: *Self) void { self.buffer.deinit(); self.* = undefined; } pub fn next(self: *Self) !?[]const u8 { while (true) { self.reader.readUntilDelimiterArrayList(&self.buffer, '\n', 4096) catch |err| switch (err) { error.EndOfStream => return null, else => return err, }; var line: []const u8 = self.buffer.items; // remove comments if (std.mem.indexOf(u8, line, "#")) |idx| { line = line[0..idx]; } // strip trailing/leading whites line = std.mem.trim(u8, line, " \r\n\t"); if (line.len == 0) { continue; } return line; } } }; } fn lineIterator(allocator: std.mem.Allocator, reader: anytype) LineIterator(@TypeOf(reader)) { return LineIterator(@TypeOf(reader)){ .reader = reader, .buffer = std.ArrayList(u8).init(allocator), }; }
0
repos
repos/wavefront-obj/README.md
# wavefront-obj A parser for wavefront object files ## Dependencies Requires package [`zlm`](https://github.com/ziglibs/zlm) to be present.
0
repos
repos/wavefront-obj/zigmod.yml
id: ejo6kd3iffi3axjpjkrvh8sjw08b0r9ipyok1kyk7q2omk1y name: wavefront-obj main: wavefront-obj.zig license: MIT description: A parser for wavefront object files dependencies: - src: git https://github.com/ziglibs/zlm
0
repos
repos/MinimalRoboticsPlatform/LICENCE.md
GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
0
repos
repos/MinimalRoboticsPlatform/README.md
# Embedded Robotics Kernel ## Goal The goal is to build a minimalistic robotic platform for embedded projects. The idea is to enable applications to run on this kernel with std support as well as a kernel-provided, robotics-specific toolset. Such a toolset includes communication, control, state handling, and other critical robotic domains. This would enable an ultra-light, simplistic and highly integrated robotic platform. The whole project is designed to support multiple boards, as for example a Raspberry Pi or a NVIDIA Jetson Nano. To begin with, basic kernel features are implemented on a virtual machine (qemu virt armv7). The end product is meant to be a compromise between a Real Time Operating system and a Microcontroller, to offer the best of both worlds on a modern Soc. The idea is that the kernel and its drivers are fixed and generically usable across Arm Socs. The actual user implementation of the projects is meant to happen in `src/environment/*yourCustomEnvironmentName*` where every new dir is a new env. Every environment is built from separately compiled user/ kernel privileged apps. The apps can talk to each other with a variety of kernel provided interfaces, such as topics, services, actions and so on. Since every app is compiled on its own and completely isolated by the kernel, regarding their communications, which is compile time defined, maximum static runtime safety and security should be given. Thanks to Zigs lazy compilation, driver handlers can be implemented and not be used or replaced, depending on the choice of board. This project is aiming to build an experience that gives the end user (developer) as much guidance and form as necessary, to build a safe and secure platform, with as much freedom as possible. This is achieved by reducing complex runtime defined communications and allocations to an absolute minimum, whilst also being flexible enough to be used across a number of boards. ## Why not Rust? I began this project in Rust but decided to switch to Zig (equally modern). Here is why. The prime argument for Rust is safety, which is also important for embedded development but has a different nature. The thing is that I very rarely (wrote) saw embedded code that really made use (at least to an extent to which it would be relevant) of Rusts safety. This is due to the fact that embedded code is mostly procedural and linear and not overly complex (opposing to higher level code). Zig on the other hand, is a real improvement compared to Rust because it does not try to solve the problem through abstraction but concepts and rules. I really tried rust at the start of this project. That lead me to this conclusion. The Rust code can still be found in the separate [rust branch](https://github.com/luickk/rust-rtos/tree/rust_code) and includes a proper Cargo build process(without making use of an external build tools) for the Raspberry, as well as basic serial(with print! macro implementation) and interrupt controller utils. ## Finding the perfect Board In order to first boot the kernel on a physical board, I'm searching for the best board. Number one priority is simplicity. The raspberry has a relatively complex multi bootstage process. That is not ideal, includes a file system on an SD Card in is pretty ugly in general. The Jetson Nano has a similarly complex boot process. The Rock Pi on the other hand offer eMMC storage that can be flashed with the Maskrom directly from another device. The Rock Pi eMMC is quite elegant because it does, a) not require a file system, and b) is loaded directly by the arm cores(and not from the GPU as with the raspberry). ## Compatibility Currently, there is support for the important Arm SOC elements such as the generic timer, interrupt controller as well as the Raspberries BCM2835 secondary interrupt controller and system timer. The project can be configured with ROM relocation and without, so most Arm SOC boards should be compatible at the moment. ## Allocation Policy Memory allocation is an extremely powerful and basic functionality that can be very dangerous depending on when and how it's used. For that reason the kernels allocations are only permitted at kernel boot/init time. There is no realloc, neither for userspace apps nor for the kernel. Alternatively, there are reserved memory buffers for every feature. I don't yet have a perfect solution for dealing with an out off memory event though. There is an app allocation available in user space so that a considered decision can be made and an allocator still be used if the app is not important. ### Allocation Projection // todo => alloc projection Since there are no allocations at actual runtime (after the kernel init), a projection of the required (allocated) memory can be made, including spare reserves. That would not only give indications for Ram compatibility, but would allow for predictions about the risk for running out of memory in case of black swan events. ## Kernel wise features ### Topics A way to share data streams with other processes, similar to pipes but optimized for sensor data and data distribution/ access over many processes. How many topics and in which configuration must be setup at compiletime in the `envConfig.zig` of the project. Note that Topics are just another type of state and are implemented in StatusControl. Each Topic can be configured in its buffer type, size, identifier and so on. In the runtime phase of the platform, every topic then behaves according to its configuration and can be addressed through its fixed id. There are two ways to communicate over a Topic, one is through SysCalls and the other is through direct mapped memory, which is very effective but less easy to use. Also, currently both ways of communicating on a Topic must not be mixed so only either one of both can be used. #### What kind of data is it for? Topics can be used for all kinds of statically sized data. Depending on the amount of data per time unit, there a re different methods of retrievals. - `fn userSysCallInterface.waitForTopicUpdate(comptime name: []const u8)` (which leverages a semaphore) can be used to wait for data in a separate thread Uses sys-calls as interface. Pushes/reads n units of the latest(depending on the buffer type) data - `fn userSysCallInterface.popFromTopic(comptime name: []const u8, ret_buff: []u8)` - `fn userSysCallInterface.pushToTopic(comptime name: []const u8, data: []u8)` Uses direct mapped memory to read/write to a Topic. Is also bound to all preconfigured parameters including the buffer type. - `fn ShareMemTopicsInterface.read(self: *SharedMemTopicsInterface, comptime name: []const u8, ret_buff: []u8)` - `fn ShareMemTopicsInterface.write(self: *SharedMemTopicsInterface, comptime name: []const u8, data: []u8)` ### Status Control A way to centrally communicate state and adapt the system appropriatly. Since the status of a sensor, service, io device, or more abstract concepts is not just a tool but one of the most important control aspects in a robotic system, this funcitonality is deeply integrated and not just meant for state sharing but also as a state machine at the heart of the system. The idea is that you can setup tasks which are only scheduled if a certain state is matching. // => todo - `fn userSysCallInterface.updateStatus(comptime name: []const u8, value: anytype) !void` - `fn userSysCallInterface.readStatus(comptime T: type, comptime name: []const u8) !T` Statuses (including topics) have to be predefined in envConfig.zig for each environment are id'ed by their name. Since all the parameters and names are compile-time that allows for safe compile time type/ name checking. The usage of names makes the code very readable and easy to understand. ### Setup Routines Are routines that run at kernel start, but before scheduler init. Meant for for driver inititation and run in kernel space. ### Kernel Threads Threads that run in kernel space, for example to handle IO that requires kernel level access or other drivers. ## User Apps Thats where the actual development is meant to happen. The user apps run, as the name suggests, in userspace and are compiled separately. Communication between all tasks is meant to happen through StatusControl(Topics, Statuses...) and Actions. ### Actions Actions are similar to apps separately compiled programs with the key difference that they are only executed(scheduled) if commanded to do so. Whilst they can run in parallel (be conventionally scheduled) their main purpose is to offer a way to start a task quickly (or roughly the time it takes to interrupt and return). If the action needs to be executed even faster, a direct (in current scheduler context) jump is inevitable (a conventional function call, for example). ## Project Structure The project aims to give as much guidance to the developer as possible, that also applies to where to put which component of the kernel. In general the projects layout looks like that: ```bash ├── build.zig ├── src/ │ ├── appLib/ │ │ ├── .. │ │ └── > everything that is linked with userspace apps │ ├── arm/ │ │ ├── .. │ │ └── > all the "drivers" required for the arm soc. linked with the kernel │ ├── boards/ │ │ ├── * contains drivers and board configuration files (qemuVirt.zig, raspi3b.zig..). Which board is compiled can be selected in build.zig, the respective configuration file is then selected and linked. * │ │ ├── drivers/ │ │ │ ├── > everything that is board specific, timer, irq, io code │ │ │ ├── bootInit/ │ │ │ │ ├── > board specific startup code that sets up the correct el, exc. vec. table,.. and and calls the bootloader entry fn. linked witht the bootloader │ │ │ │ ├── qemuVirt_boot.S │ │ │ │ └── .. │ │ │ ├── interruptController/ │ │ │ │ ├── > board specific drivers for additional(to the arm gic) interrupt controllers, linked with the kernel │ │ │ │ ├── bcm2835InterruptController.zig │ │ │ │ └── .. │ │ │ └── timer/ │ │ │ ├── > board specific drivers for additional(to the arm gt) timer, linked with the kernel │ │ │ ├── bcm2835Timer.zig │ │ │ └── .. │ │ ├── qemuVirt.zig │ │ └── .. │ ├── bootloader/ │ │ ├── bins/ │ │ │ └── > the kernels binary (non elf format) is saved here because it is embedded by the bootloader (usings Zigs `@embedFile`) and cannot be placed outside the package path │ │ ├── .. │ │ └── > contains everything required to make the bootloader boot the kernel │ ├── configTemplates/ │ │ ├── .. │ │ └── > contains all the templates for different configurations. E.g. the board or env. configuration │ ├── environments/ │ │ ├── > actual development space. Every environment is a set of userspace apps and kernel threads. Only one environment at a time can be compiled. Which environment is compiled can be selected in the build.zig. │ │ ├── basicKernelFunctionalityTest/ │ │ │ ├── > environment for basic kernel integration tests. In the envConfig.zig everthing environment can be configured. E.g. how many topics, with which buffer type they operate and so on.. │ │ │ ├── envConfig.zig │ │ │ ├── kernelThreads/ │ │ │ │ ├── > all kernel threads required by the board. E.g. a handler for the additional(or secondary) interrupt controller. linked with the kernel! │ │ │ │ ├── threads.zig │ │ │ │ └── .. │ │ │ ├── setupRoutines/ │ │ │ │ ├── > setup routines called on kernel entry. E.g. the init of additional interrupt controller handler. linked with the kernel! │ │ │ │ ├── routines.zig │ │ │ │ └── .. │ │ │ └── userApps/ │ │ │ ├── > actual userspace with all the userspace apps. every app is build seperately │ │ │ ├── _semaphoreTest/ > (apps starting with underscore and not compiled..) │ │ │ │ ├── linker.ld │ │ │ │ └── main.zig │ │ │ └── mutexTest/ │ │ │ ├── linker.ld │ │ │ └── main.zig │ │ ├── .. │ ├── kernel/ │ │ ├── > actual kernel space │ │ ├── bins/ │ │ │ ├── .. │ │ │ └── > app binaries are saved here because they are embedded by the kernel (user Zigs `@embedFile`) and cannot be placed outside the package path/ │ │ ├── exc_vec.S │ │ ├── kernel.zig │ │ ├── .. │ │ ├── sharedKernelServices/ │ │ │ ├── SysCallsTopicsInterface.zig │ │ │ ├── .. │ │ │ └── > all services that have to be accessed over from the drivers for exampled., linked with the kernel │ ├── kpi/ │ │ ├── secondaryInterruptControllerKpi.zig │ │ ├── .. │ │ └── > kernel programming interface for drivers. e.g. the timer or secondary irq handler driver. inited in the board configuration file │ ├── periph/ │ │ ├── pl011.zig │ │ ├── .. │ │ └── > all the peripheral devices code │ ├── sharedServices/ │ │ ├── Topic.zig │ │ ├── .. │ │ └── > code thats so basic that it is linked with both the kernel and the userspace │ └── utils │ └── utils.zig ``` # Kernel details ## Bootloader and kernel separation Because it simplifies linking and building the kernel as a whole. Linking both the kernel and bootloader is difficult(and error-prone) because it requires the linker to link symbols with VMA offsets that are not supported in size and causes more issues when it comes to relocation of the kernel.  Both the bootloader and kernel are compiled&linked separately, then their binaries are concatenated(all in build.zig). The bootloader then prepares the exception vectors, mmu, memory drivers and relocates the kernel code. The bootloader is really custom and does a few things differently. One of the primary goals is to keep non static memory allocations to an absolute minimum. This is also true for the stack/ paging tables, which have to be loaded at runtime. At the moment both, bootloader stack and page tables are allocated on the ram, to be more specific in the specified userspace section. This allows to boot from rom(non writable memory...) whilst still supporting boot from ram. ## MMU I wrote a mmu "composer" with which one can simply configure and then generate/ write the pagetables. The page table generation supports 3 lvls and 4-16k granule. 64k is also possible but another level has to be added to the `TransLvl` enum in `src/board/boardConfig.zig` and it's not fully tested yet. Ideally I wanted the page tables to be generated at comptime, but in order to have multiple translation levels, the mmu needs absolute physical addresses, which cannot be known at compile time(only relative addresses). Alternatively the memory can be statically reserved and written at runtime, which is not an option for the bootloader though because it is possibly located in rom, and cannot write to statically reserved memory, leaving the only option, allocating the bootloader page table on the ram (together with the stack). The kernel on the other hand could reserve at least the kernel space page tables, since they are static in size, but for consistency reasons kernel and userspace have linker-reserved memory. ### Addresses The Arm mmu is really powerful and complex in order to be flexible. For this project the mmu is not required to be flexible, but safe and simple. For an embedded robotics platform it's neither required to have a lot of storage, nor to control the granularity in an extremely fine scope since most of the memory is static anyways. Additionally devices as for example the Raspberry Pi forbid Lvl 0 translation at all since it's 512gb at 4k granule which is unnecessary for such a device. With those constraints in place, this project only supports translation tables beginning at lvl 1, which is also why, `vaStart` is `0xFFFFFF8000000000`, since that's the lowest possible virtual address in lvl 1. ### Qemu Testing In order to test the bootloader/ kernel, qemu offers `-kernel` but that includes a number of abstractions that are not wanted since I want to keep the development at least somewhat close to a real board. Instead, the booloader (which includes the kernel) is loaded with `-device loader`. ## Implementations ### CPU #### Interrupt controller The Raspberry ships with the BCM2835, which is based on the Arm A53 but does not adapt its interrupt controller. More about the BCM2835s ic can be found [here](https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf)(p109) and [here](https://xinu.cs.mu.edu/index.php/BCM2835_Interrupt_Controller). The [linux driver implementation](https://github.com/torvalds/linux/blob/master/drivers/irqchip/irq-bcm2835.c) comments are also worth looking at. #### MMU The best lecture to understand the MMU is probably the [official Arm documentation](https://developer.arm.com/documentation/100940/0101), which does a very good job of explaining the concepts of the mmu. Since this project requires multiple applications running at the same time, virtual memory is indispensable for safety and performance. ## Installation ### Dependencies: - zig (last tested version 0.10.1) - qemu (for testing) ### Run - `zig build qemu` Builds and runs the project. The environment and board as well as all the other parameters for the build can be configured in build.zig
0
repos
repos/MinimalRoboticsPlatform/build.zig
const std = @import("std"); const warn = std.debug.warn; const os = std.os; const BoardBuildConf = @import("src/configTemplates/boardBuildConfigTemplate.zig").BoardBuildConf; const builtin = @import("builtin"); const Error = error{BlExceedsRomSize}; const Module = std.build.Module; const ModuleDependency = std.build.ModuleDependency; const raspi3b = BoardBuildConf{ .boardName = "raspi3b", .has_rom = false, .rom_start_addr = null, // is duplicate and has to be changed here and in the runtime config file .va_start = 0xFFFFFF8000000000, // is duplicat and address to which the bl is loaded if there is NO rom(which is the case for the raspberry 3b)! // if there is rom, the bootloader must be loaded to 0x0 (and bl_load_addr = null) .bl_load_addr = 0x80000, // , "-d", "trace:bcm2835_systmr*", "-D", "./log.txt" .qemu_launch_command = &[_][]const u8{ "qemu-system-aarch64", "-machine", "raspi3b", "-device", "loader,addr=0x80000,file=zig-out/bin/bootloader.bin,cpu-num=0,force-raw=on", "-serial", "stdio", "-display", "none" }, }; const qemuVirt = BoardBuildConf{ .boardName = "qemuVirt", .has_rom = true, // qemus virt machine has no rom .rom_start_addr = 0, // is duplicate and has to be changed here and in the runtime config file .va_start = 0xFFFFFF8000000000, // is duplicat and address to which the bl is loaded if there is NO rom(which is the case for the raspberry 3b)! // if there is rom, the bootloader must be loaded to 0x0 (and bl_load_addr = null) .bl_load_addr = null, // arm_gt, gic // "-d", "trace:gic*", "-D", "./log.txt" .qemu_launch_command = &[_][]const u8{ "qemu-system-aarch64", "-machine", "virt", "-m", "10G", "-cpu", "cortex-a53", "-device", "loader,file=zig-out/bin/bootloader.bin,cpu-num=0,force-raw=on", "-serial", "stdio", "-display", "none" }, }; // const currBoard = raspi3b; const currBoard = qemuVirt; // const env_path = "src/environments/statusControlTest"; // const env_path = "src/environments/basicMultiProcess"; // const env_path = "src/environments/basicMultithreading"; // const env_path = "src/environments/multiProcAndThreading"; // const env_path = "src/environments/sysCallTopicsTest"; // const env_path = "src/environments/sharedMemTopicsTest"; const env_path = "src/environments/basicKernelFunctionalityTest"; // const env_path = "src/environments/actionTest"; pub fn build(b: *std.Build) !void { // currBoard.config.checkConfig(); const build_mode = std.builtin.Mode.ReleaseFast; const build_options = b.addOptions(); // packages... // SOC builtin features var arm = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "arm", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/arm/arm.zig" } }) }; // package for kernel interfaces such as the timer or the interrupt controller or general drivers var kpi = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "kpi", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/kpi/kpi.zig" } }) }; // functions generally required var utils = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "utils", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/utils/utils.zig" } }) }; // board pkg contains the configuration "template"(boardConfig.zig) and different configuration files for different boards var board = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "board", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/boards/" ++ currBoard.boardName ++ ".zig" } }) }; var environment = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "environment", .{}), .module = b.createModule(.{ .source_file = .{ .path = env_path ++ "/envConfig.zig" } }) }; // peripheral drivers var periph = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "periph", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/periph/periph.zig" } }) }; // services that need to be accessed by kernel and other instances. the kernel allocator e.g. var sharedKernelServices = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "sharedKernelServices", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/kernel/sharedKernelServices/sharedKernelServices.zig" } }) }; // package for all applications to call syscall var appLib = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "appLib", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/appLib/appLib.zig" } }) }; const configTemplates = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "configTemplates", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/configTemplates/configTemplates.zig" } }) }; //kernel threads var kernelThreads = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "kernelThreads", .{}), .module = b.createModule(.{ .source_file = .{ .path = env_path ++ "/kernelThreads/threads.zig" } }) }; var setupRoutines = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "setupRoutines", .{}), .module = b.createModule(.{ .source_file = .{ .path = env_path ++ "/setupRoutines/routines.zig" } }) }; // driver packages var interruptControllerDriver = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "interruptControllerDriver", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/boards/drivers/interruptController/interruptController.zig" } }) }; var timerDriver = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "timerDriver", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/boards/drivers/timer/timer.zig" } }) }; var sharedServices = ModuleDependency{ .name = try std.fmt.allocPrint(b.allocator, "sharedServices", .{}), .module = b.createModule(.{ .source_file = .{ .path = "src/sharedServices/sharedServices.zig" } }) }; // inter package dependencies const kernelThreads_deps = [_]ModuleDependency{ board, arm, sharedKernelServices, periph }; kernelThreads.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &kernelThreads_deps); const setupRoutines_deps = [_]ModuleDependency{ board, arm, sharedKernelServices, periph }; setupRoutines.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &setupRoutines_deps); const kpi_deps = [_]ModuleDependency{ sharedKernelServices, arm }; kpi.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &kpi_deps); const interruptControllerDriver_deps = &[_]ModuleDependency{ board, arm }; interruptControllerDriver.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, interruptControllerDriver_deps); const timerDriver_deps = [_]ModuleDependency{ board, utils, periph }; timerDriver.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &timerDriver_deps); const board_deps = [_]ModuleDependency{ kpi, utils, arm, interruptControllerDriver, timerDriver, configTemplates }; board.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &board_deps); const environment_deps = [_]ModuleDependency{configTemplates}; environment.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &environment_deps); const sharedServices_deps = [_]ModuleDependency{ board, appLib, environment }; sharedServices.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &sharedServices_deps); const sharedKernelServices_deps = [_]ModuleDependency{ board, environment, appLib, arm, utils, sharedServices, periph }; sharedKernelServices.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &sharedKernelServices_deps); const periph_deps = [_]ModuleDependency{board}; periph.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &periph_deps); const utils_deps = [_]ModuleDependency{ board, arm }; utils.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &utils_deps); const arm_deps = [_]ModuleDependency{ periph, utils, board, sharedKernelServices }; arm.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &arm_deps); const appLib_deps = [_]ModuleDependency{ board, utils, environment, sharedServices, sharedKernelServices }; appLib.module.dependencies = moduleDependenciesToArrayHashMap(b.allocator, &appLib_deps); const temp_kernel_ld = "zig-cache/tmp/tempKernelLinker.ld"; const temp_bl_ld = "zig-cache/tmp/tempBlLinker.ld"; // compilation steps const update_linker_scripts_bl = UpdateLinkerScripts.create(b, .bootloader, temp_bl_ld, temp_kernel_ld, currBoard); const update_linker_scripts_k = UpdateLinkerScripts.create(b, .kernel, temp_bl_ld, temp_kernel_ld, currBoard); const scan_for_apps = ScanForApps.create(b, build_options); const build_and_run = b.step("qemu", "emulate the kernel with no graphics and output uart to console"); const build_kernel_and_bootloader = b.step("kernel_and_bootloader", "building the kernel and the bootloader(which embedds the kernel)"); // const launch_with_gdb = b.option(bool, "gdb", "Launch qemu with -s -S to allow for net gdb debugging") orelse false; // ------- apps/ actions const apps_and_action_step = try setEnvironment(b, build_mode, env_path, [4]ModuleDependency{ periph, board, configTemplates, appLib }); // ------- kernel const kernel_exe = b.addExecutable(.{ .name = "kernel", .target = .{ .cpu_arch = std.Target.Cpu.Arch.aarch64, .os_tag = std.Target.Os.Tag.freestanding, .abi = std.Target.Abi.eabihf }, .optimize = build_mode, }); kernel_exe.force_pic = false; kernel_exe.pie = false; kernel_exe.code_model = .large; kernel_exe.strip = false; kernel_exe.addModule(arm.name, arm.module); kernel_exe.addModule(sharedKernelServices.name, sharedKernelServices.module); kernel_exe.addModule(appLib.name, appLib.module); kernel_exe.addModule(sharedServices.name, sharedServices.module); kernel_exe.addModule(utils.name, utils.module); kernel_exe.addModule(kpi.name, kpi.module); kernel_exe.addModule(board.name, board.module); kernel_exe.addModule(environment.name, environment.module); kernel_exe.addModule(periph.name, periph.module); kernel_exe.addModule(interruptControllerDriver.name, interruptControllerDriver.module); kernel_exe.addModule(timerDriver.name, timerDriver.module); kernel_exe.addModule(kernelThreads.name, kernelThreads.module); kernel_exe.addModule(setupRoutines.name, setupRoutines.module); kernel_exe.addOptions("build_options", build_options); kernel_exe.setLinkerScriptPath(.{ .path = temp_kernel_ld }); kernel_exe.addObjectFile(.{ .path = "src/kernel/kernel.zig" }); kernel_exe.addCSourceFile(.{ .file = .{ .path = "src/kernel/exc_vec.S" }, .flags = undefined }); kernel_exe.step.dependOn(&update_linker_scripts_k.step); kernel_exe.step.dependOn(&scan_for_apps.step); kernel_exe.step.dependOn(apps_and_action_step); const install_kernel_raw = kernel_exe.addObjCopy(.{ .format = .bin }); const install_kernel_bin = b.addInstallBinFile(install_kernel_raw.getOutput(), "../../src/bootloader/bins/kernel.bin"); install_kernel_raw.step.dependOn(&kernel_exe.step); install_kernel_bin.step.dependOn(&install_kernel_raw.step); // ------- bootloader const bl_exe = b.addExecutable(.{ .name = "bootloader", .target = .{ .cpu_arch = std.Target.Cpu.Arch.aarch64, .os_tag = std.Target.Os.Tag.freestanding, .abi = std.Target.Abi.eabihf }, .optimize = build_mode, }); bl_exe.force_pic = false; bl_exe.pie = false; bl_exe.code_model = .large; bl_exe.addModule(arm.name, arm.module); bl_exe.addModule(utils.name, utils.module); bl_exe.addModule(board.name, board.module); bl_exe.addModule(periph.name, periph.module); bl_exe.addOptions("build_options", build_options); bl_exe.setLinkerScriptPath(std.build.FileSource{ .path = temp_bl_ld }); bl_exe.addObjectFile(.{ .path = "src/bootloader/bootloader.zig" }); bl_exe.addCSourceFile(.{ .file = .{ .path = "src/boards/drivers/bootInit/" ++ currBoard.boardName ++ "_boot.S" }, .flags = undefined }); bl_exe.addCSourceFile(.{ .file = .{ .path = "src/bootloader/exc_vec.S" }, .flags = undefined }); bl_exe.step.dependOn(&update_linker_scripts_bl.step); const install_bl_raw = bl_exe.addObjCopy(.{ .format = .bin }); const install_bl_bin = b.addInstallBinFile(install_kernel_raw.getOutput(), "bootloader.bin"); bl_exe.step.dependOn(&install_kernel_bin.step); install_bl_raw.step.dependOn(&bl_exe.step); install_bl_bin.step.dependOn(&install_bl_raw.step); // ------- BUILD/ QEMU build_kernel_and_bootloader.dependOn(&install_bl_bin.step); const qemu_launch_cmd = b.addSystemCommand(currBoard.qemu_launch_command); qemu_launch_cmd.step.dependOn(&install_bl_bin.step); build_and_run.dependOn(&qemu_launch_cmd.step); } fn setEnvironment(b: *std.Build, build_mode: std.builtin.Mode, comptime path: []const u8, app_deps: [4]ModuleDependency) !*std.Build.Step { const user_apps_path = path ++ "/userApps/"; var dir = try std.fs.cwd().openIterableDir(user_apps_path, .{}); var it = dir.iterate(); const apps_action_step = b.step("apps_actions", "compiles apps and actions"); while (try it.next()) |folder| { if (folder.kind != .directory or folder.name[0] == '_' or std.mem.eql(u8, folder.name, "actions")) continue; const app = try addApp(b, build_mode, try std.fmt.allocPrint(b.allocator, "{s}/{s}", .{ user_apps_path, folder.name }), app_deps); const install_app_raw = app.addObjCopy(.{ .format = .bin }); const install_app_bin = b.addInstallBinFile(install_app_raw.getOutput(), try std.fmt.allocPrint(b.allocator, "../../src/kernel/bins/actions/{s}", .{folder.name})); install_app_raw.step.dependOn(&app.step); install_app_bin.step.dependOn(&install_app_raw.step); apps_action_step.dependOn(&install_app_bin.step); } const actions_path = path ++ "/userApps/actions/"; dir = try std.fs.cwd().openIterableDir(actions_path, .{}); it = dir.iterate(); while (try it.next()) |folder| { if (folder.kind != .directory or folder.name[0] == '_' or std.mem.eql(u8, folder.name, "actions")) continue; const action = try addApp(b, build_mode, try std.fmt.allocPrint(b.allocator, "{s}/{s}", .{ actions_path, folder.name }), app_deps); const install_action_raw = action.addObjCopy(.{ .format = .bin }); const install_action_bin = b.addInstallBinFile(install_action_raw.getOutput(), try std.fmt.allocPrint(b.allocator, "../../src/kernel/bins/apps/{s}", .{folder.name})); install_action_raw.step.dependOn(&action.step); install_action_bin.step.dependOn(&install_action_raw.step); apps_action_step.dependOn(&install_action_bin.step); } return apps_action_step; } fn addApp(b: *std.Build, build_mode: std.builtin.Mode, path: []const u8, app_deps: [4]ModuleDependency) !*std.Build.Step.Compile { const app = b.addExecutable(.{ .name = std.fs.path.basename(path), .target = .{ .cpu_arch = std.Target.Cpu.Arch.aarch64, .os_tag = std.Target.Os.Tag.freestanding, .abi = std.Target.Abi.eabihf }, .optimize = build_mode, }); app.force_pic = false; app.pie = false; app.setLinkerScriptPath(std.build.FileSource{ .path = try std.fmt.allocPrint(b.allocator, "{s}/linker.ld", .{path}) }); app.addObjectFile(.{ .path = try std.fmt.allocPrint(b.allocator, "{s}/main.zig", .{path}) }); for (app_deps) |dep| app.addModule(dep.name, dep.module); // app.step.dependOn(&b.addInstallArtifact(app, .{}).step); return app; } const UpdateLinkerScripts = struct { pub const ToUpdate = enum { bootloader, kernel }; step: std.build.Step, temp_bl_ld: []const u8, temp_kernel_ld: []const u8, board_config: BoardBuildConf, to_update: ToUpdate, allocator: std.mem.Allocator, pub fn create(b: *std.Build, to_update: ToUpdate, temp_bl_ld: []const u8, temp_kernel_ld: []const u8, board_config: BoardBuildConf) *UpdateLinkerScripts { const self = b.allocator.create(UpdateLinkerScripts) catch unreachable; self.* = .{ .step = std.build.Step.init(.{ .id = .custom, .name = "UpdateLinkerScript", .owner = b, .makeFn = UpdateLinkerScripts.doStep }), .temp_bl_ld = temp_bl_ld, .temp_kernel_ld = temp_kernel_ld, .board_config = board_config, .to_update = to_update, .allocator = b.allocator, }; return self; } /// inserts args variables (in order), defined in inp_linker_script_path in outp_linker_script_path // bc file reads cannot be comptime (and the loop not be unrolled), arr size is static and elements optional // if more args are required just increase arr size (will have to pad all fn calls with fewer args in list!.) fn writeVarsToLinkerScript(a: std.mem.Allocator, inp_linker_script_path: []const u8, outp_linker_script_path: []const u8, args: [3]?usize) !void { var in_file = try std.fs.cwd().openFile(inp_linker_script_path, .{}); defer in_file.close(); var buf_reader = std.io.bufferedReader(in_file.reader()); var in_stream = buf_reader.reader(); const out_file = try std.fs.cwd().createFile(outp_linker_script_path, .{}); defer out_file.close(); var buf: [1024]u8 = undefined; var args_conv_buff: [1024]u8 = undefined; var args_i: usize = 0; var outp_line = std.ArrayList(u8).init(a); var j: usize = 0; var to_insert: []u8 = undefined; while (try in_stream.readUntilDelimiterOrEof(&buf, '\n')) |line| { try outp_line.appendSlice(line); for (line, 0..) |c, i| { if (c == '{' and i + 4 <= line.len) { if (std.mem.eql(u8, line[i .. i + 6], "{@zig}")) { while (j < 6) : (j += 1) { _ = outp_line.orderedRemove(i); } j = 0; if (args[args_i]) |arg| { to_insert = std.fmt.bufPrintIntToSlice(&args_conv_buff, arg, 10, .lower, .{}); try outp_line.insertSlice(i, to_insert); } else { return (error{TooFewArgs}).TooFewArgs; } args_i += 1; } } } try out_file.writeAll(outp_line.items); try out_file.writeAll("\n"); outp_line.clearAndFree(); } } fn doStep(step: *std.build.Step, prog_node: *std.Progress.Node) !void { _ = prog_node; const self = @fieldParentPtr(UpdateLinkerScripts, "step", step); switch (self.to_update) { .bootloader => { var bl_start_address: usize = self.board_config.rom_start_addr orelse 0; if (!self.board_config.has_rom) bl_start_address = self.board_config.bl_load_addr orelse 0; // // in case there is no rom(rom_size is equal to zero) and the kernel(and bl) are directly loaded to memory by some rom bootloader // // the ttbr0 memory is also identity mapped to the ram // var bl_pt_size_ttbr0: usize = (currBoard.config.mem.rom_size orelse 0) + currBoard.config.mem.ram_size; // if (!currBoard.config.mem.has_rom) // bl_pt_size_ttbr0 = currBoard.config.mem.ram_size; try writeVarsToLinkerScript(self.allocator, "src/bootloader/linker.ld", self.temp_bl_ld, .{ bl_start_address, null, null, }); }, .kernel => { try writeVarsToLinkerScript(self.allocator, "src/kernel/linker.ld", self.temp_kernel_ld, .{ currBoard.va_start, null, null, }); }, } } }; const ScanForApps = struct { step: std.build.Step, builder: *std.Build, build_options: *std.build.OptionsStep, pub fn create(b: *std.Build, build_options: *std.build.OptionsStep) *ScanForApps { const self = b.allocator.create(ScanForApps) catch unreachable; self.* = .{ .step = std.build.Step.init(.{ .id = .custom, .name = "ScanForApps", .owner = b, .makeFn = ScanForApps.doStep }), .builder = b, .build_options = build_options }; return self; } fn doStep(step: *std.build.Step, prog_node: *std.Progress.Node) !void { _ = prog_node; const self = @fieldParentPtr(ScanForApps, "step", step); // searching for apps in apps/ { var apps = std.ArrayList([]const u8).init(self.builder.allocator); var actions = std.ArrayList([]const u8).init(self.builder.allocator); defer actions.deinit(); defer apps.deinit(); var dir = std.fs.cwd().openIterableDir("zig-out/bin/apps/", .{}) catch |e| { if (e == error.FileNotFound) { self.build_options.addOption([]const []const u8, "apps", &.{}); return; } else return e; }; var it = dir.iterate(); while (try it.next()) |file| { if (file.kind != .file) continue; try apps.append(file.name); } self.build_options.addOption([]const []const u8, "apps", apps.items); dir = std.fs.cwd().openIterableDir("zig-out/bin/actions/", .{}) catch |e| { if (e == error.FileNotFound) { self.build_options.addOption([]const []const u8, "actions", &.{}); return; } else return e; }; it = dir.iterate(); while (try it.next()) |file| { if (file.kind != .file) continue; try actions.append(file.name); } self.build_options.addOption([]const []const u8, "actions", actions.items); } } }; // std zig build additions fn moduleDependenciesToArrayHashMap(arena: std.mem.Allocator, deps: []const ModuleDependency) std.StringArrayHashMap(*Module) { var result = std.StringArrayHashMap(*Module).init(arena); for (deps) |dep| { result.put(dep.name, dep.module) catch @panic("OOM"); } return result; }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/sharedServices/Topic.zig
const std = @import("std"); const utils = @import("utils"); const board = @import("board"); const env = @import("environment"); const TopicBufferTypes = env.envConfTemplate.TopicBufferTypes; const appLib = @import("appLib"); const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; // todo => permission restrictions // changes behaviour based on runtime information pub const UsersapceMultiBuff = struct { const Error = error{ MaxRollOvers, }; buff: []u8, behaviour_type: TopicBufferTypes, // this is the only state which is restored, all other variables will reset upon each call when used by SharedMemTopicsInterface curr_read_write_ptr: *volatile usize, pub fn init(topic_mem: []u8, buff_curr_read_write_ptr_state: *volatile usize, buff_type: TopicBufferTypes) UsersapceMultiBuff { return .{ .buff = topic_mem, .behaviour_type = buff_type, .curr_read_write_ptr = buff_curr_read_write_ptr_state }; } pub fn write(self: *UsersapceMultiBuff, data: []u8) !usize { switch (self.behaviour_type) { .RingBuffer => { return self.write_ring_buff(data); }, .ContinousBuffer => { return self.write_continous_buff(data); }, } } pub fn read(self: *UsersapceMultiBuff, ret_buff: []u8) !usize { switch (self.behaviour_type) { .RingBuffer => { return self.read_ring_buff(ret_buff); }, .ContinousBuffer => { return self.read_continous_buff(ret_buff); }, } } pub fn write_ring_buff(self: *UsersapceMultiBuff, data: []u8) !usize { var space_left: usize = 0; if (self.curr_read_write_ptr.* + data.len > self.buff.len) { space_left = self.buff.len - try std.math.mod(usize, self.curr_read_write_ptr.*, self.buff.len); } else space_left = data.len; std.mem.copy(u8, self.buff[self.curr_read_write_ptr.* .. self.curr_read_write_ptr.* + space_left], data); self.curr_read_write_ptr.* += data.len; return space_left; } pub fn read_ring_buff(self: *UsersapceMultiBuff, ret_buff: []u8) !usize { // if (asm volatile ("adr %[pc], ." // : [pc] "=r" (-> usize), // ) < 0xFFFFFF8000000000) kprint("curr read curr_read_write_ptr: {any} \n", .{self.curr_read_write_ptr}); var ret_data: []u8 = undefined; if (self.curr_read_write_ptr.* < ret_buff.len) { ret_data = self.buff[0..self.curr_read_write_ptr.*]; self.curr_read_write_ptr.* = 0; } else { ret_data = self.buff[self.curr_read_write_ptr.* - ret_buff.len .. self.curr_read_write_ptr.*]; self.curr_read_write_ptr.* -= ret_buff.len; } std.mem.copy(u8, ret_buff, ret_data); return ret_data.len; } pub fn write_continous_buff(self: *UsersapceMultiBuff, data: []u8) !usize { const buff_pointer = try std.math.mod(usize, self.curr_read_write_ptr.*, self.buff.len); std.mem.copy(u8, self.buff[buff_pointer..], data); if (buff_pointer + data.len > self.buff.len) { std.mem.copy(u8, self.buff[0..], data[self.buff.len..]); } self.curr_read_write_ptr.* += data.len; return data.len; } pub fn read_continous_buff(self: *UsersapceMultiBuff, ret_buff: []u8) !usize { // if (asm volatile ("adr %[pc], ." // : [pc] "=r" (-> usize), // ) < 0xFFFFFF8000000000) kprint("curr read curr_read_write_ptr: {any} \n", .{self.curr_read_write_ptr.*}); const buff_pointer = try std.math.mod(usize, self.curr_read_write_ptr.*, self.buff.len); var lower_read_bound: usize = 0; if (buff_pointer > ret_buff.len) lower_read_bound = buff_pointer - ret_buff.len; const data = self.buff[lower_read_bound..buff_pointer]; std.mem.copy(u8, ret_buff, data); var rolled_over_data: []u8 = undefined; if (buff_pointer < ret_buff.len and buff_pointer != 0) { const rollover_size: usize = std.math.absCast(try std.math.sub(isize, @as(isize, @intCast(buff_pointer)), @as(isize, @intCast(ret_buff.len)))); // only one rollver is supported if (rollover_size > self.buff.len) return Error.MaxRollOvers; rolled_over_data = self.buff[self.buff.len - rollover_size .. self.buff.len]; var ret_buff_slice: []u8 = undefined; ret_buff_slice.ptr = @ptrFromInt(@intFromPtr(ret_buff.ptr) + data.len); ret_buff_slice.len = data.len; std.mem.copy(u8, ret_buff_slice, rolled_over_data); } return data.len + rolled_over_data.len; } }; pub fn Topic(comptime Semaphore: type) type { return struct { const Self = @This(); buff: UsersapceMultiBuff, id: usize, opened: bool, waiting_tasks: [board.config.static_memory_reserves.topics_max_process_in_queue]?Semaphore, n_waiting_taks: usize, pub fn init(topics_mem: []u8, buff_curr_read_write_ptr_state: *volatile usize, id: usize, buff_type: TopicBufferTypes) Self { return .{ .buff = UsersapceMultiBuff.init(topics_mem, buff_curr_read_write_ptr_state, buff_type), .id = id, .opened = false, .waiting_tasks = [_]?Semaphore{null} ** board.config.static_memory_reserves.topics_max_process_in_queue, .n_waiting_taks = 0, }; } pub fn write(self: *Self, data: []u8) !usize { return self.buff.write(data); } pub fn read(self: *Self, ret_buff: []u8) !usize { return self.buff.read(ret_buff); } }; }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/sharedServices/sharedServices.zig
pub const Topic = @import("Topic.zig").Topic;
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/utils.zig
const kprint = @import("periph").uart.UartWriter(.ttbr0).kprint; pub fn panic() noreturn { kprint("[kernel] panic \n", .{}); while (true) {} }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/kernelIntHandler.zig
const std = @import("std"); const arm = @import("arm"); const ProccessorRegMap = arm.processor.ProccessorRegMap; const CpuContext = arm.cpuContext.CpuContext; const k_utils = @import("utils.zig"); const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const board = @import("board"); const sysCalls = @import("sysCalls.zig"); // const bcm2835IntHandle = @import("board/raspi3b/bcm2835IntHandle.zig"); const gic = arm.gicv2; const gt = arm.genericTimer; pub fn trapHandler(on_stack_context: *CpuContext, tmp_int_type: usize) callconv(.C) void { const int_type = tmp_int_type; // copy away from stack top (unsure about C abi standards...) var context = on_stack_context.*; // kprint("unique \n", .{}); context.int_type = int_type; // kprint("cpucontext size: {d} \n", .{@sizeOf(CpuContext)}); // kprint("context: {any} \n", .{context}); // kprint("pc: {x} \n", .{ProccessorRegMap.getCurrentPc()}); const int_type_en = std.meta.intToEnum(gic.ExceptionType, int_type) catch { printExc(&context, null); return; }; switch (int_type_en) { .el0Sync, .el1Sync => { const ec = @as(u6, @truncate(context.esr_el1 >> 26)); const ec_en = std.meta.intToEnum(ProccessorRegMap.Esr_el1.ExceptionClass, ec) catch { kprint("Error decoding ExceptionClass 0x{x} \n", .{ec}); printExc(&context, int_type_en); return; }; switch (ec_en) { .svcInstExAArch64 => { var sys_call_found: bool = false; for (&sysCalls.sysCallTable) |*sys_call| { if (sys_call.id == context.x8) { sys_call.fn_call(on_stack_context); sys_call_found = true; } } if (!sys_call_found) { kprint("[kernel] SysCall id NOT found! \n", .{}); printExc(&context, int_type_en); } }, .bkptInstExecAarch64 => { kprint("[app] halting execution due to debug trap\n", .{}); printContext(&context); kprint("pc: 0x{x}\n", .{ProccessorRegMap.getCurrentPc()}); haltExec(true, on_stack_context); }, else => { printExc(&context, int_type_en); }, } }, // timer interrupts with custom timers per board .el1Irq, .el0Irq => { if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { if (secondary_ic.context.handler_fn) |handler| handler(&context); } if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(&context) catch |e| { kprint("kernel timer error {s} \n", .{@errorName(e)}); return; }; } }, else => { printExc(&context, int_type_en); }, } } fn printExc(context: *CpuContext, int_type_en: ?gic.ExceptionType) void { // printing debug information const iss = @as(u25, @truncate(context.esr_el1)); const ifsc = @as(u6, @truncate(context.esr_el1)); const il = @as(u1, @truncate(context.esr_el1 >> 25)); const ec = @as(u6, @truncate(context.esr_el1 >> 26)); const iss2 = @as(u5, @truncate(context.esr_el1 >> 32)); _ = iss; _ = iss2; kprint(".........sync exc............\n", .{}); if (int_type_en) |int_type| kprint("Int Type: {s} \n", .{@tagName(int_type)}); const ec_en = std.meta.intToEnum(ProccessorRegMap.Esr_el1.ExceptionClass, ec) catch { kprint("Error decoding ExceptionClass 0x{x} \n", .{ec}); printContext(context); return; }; const ifsc_en = std.meta.intToEnum(ProccessorRegMap.Esr_el1.Ifsc, ifsc) catch { kprint("Error decoding ExceptionClass IFSC 0x{x} \n", .{ifsc}); printContext(context); return; }; kprint("Exception Class(from esp reg): {s} \n", .{@tagName(ec_en)}); kprint("IFC(from esp reg): {s} \n", .{@tagName(ifsc_en)}); kprint("- debug info: \n", .{}); printContext(context); kprint(".........sync exc............\n", .{}); if (il == 1) { kprint("32 bit instruction trapped \n", .{}); } else { kprint("16 bit instruction trapped \n", .{}); } kprint(".........sync exc............\n", .{}); } fn printContext(context: *CpuContext) void { kprint("--------- context --------- \n", .{}); kprint("irq el: {d} \n", .{context.el}); kprint("far_el1: 0x{x} \n", .{context.far_el1}); kprint("irq esr_el1: 0x{x} \n", .{context.esr_el1}); kprint("irq elr_el1: 0x{x} \n", .{context.elr_el1}); kprint("- sys regs: \n", .{}); kprint("sp_el0: 0x{x} \n", .{context.sp_el0}); kprint("lr(x30): 0x{x} \n", .{context.x30}); kprint("irq sp_el1: 0x{x} \n", .{context.sp_el1}); kprint("irq spSel: {d} \n", .{context.sp_sel}); kprint("x0: 0x{x}, x1: 0x{x}, x2: 0x{x}, x3: 0x{x}, x4: 0x{x} \n", .{ context.x0, context.x1, context.x2, context.x3, context.x4 }); kprint("x5: 0x{x}, x6: 0x{x}, x7: 0x{x}, x8: 0x{x}, x9: 0x{x} \n", .{ context.x5, context.x6, context.x7, context.x8, context.x9 }); kprint("x10: 0x{x}, x11: 0x{x}, x12: 0x{x}, x13: 0x{x}, x14: 0x{x} \n", .{ context.x10, context.x11, context.x12, context.x13, context.x14 }); kprint("x15: 0x{x}, x16: 0x{x}, x17: 0x{x}, x18: 0x{x}, x19: 0x{x} \n", .{ context.x15, context.x16, context.x17, context.x18, context.x19 }); kprint("x20: 0x{x}, x21: 0x{x}, x22: 0x{x}, x23: 0x{x}, x24: 0x{x} \n", .{ context.x20, context.x21, context.x22, context.x23, context.x24 }); kprint("x25: 0x{x}, x26: 0x{x}, x27: 0x{x}, x28: 0x{x}, x29: 0x{x} \n", .{ context.x25, context.x26, context.x27, context.x28, context.x29 }); kprint("--------- context --------- \n", .{}); } fn haltExec(halt_execution: bool, on_stack_context: *CpuContext) void { if (!halt_execution) { on_stack_context.elr_el1 += 4; } else { while (true) {} } }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/tests.zig
const kprint = @import("periph").uart.UartWriter(.ttbr1).kprint; pub fn testUserPageAlloc(alloc: anytype) !void { const p1 = try alloc.allocNPage(10); const p2 = try alloc.allocNPage(10); const p3 = try alloc.allocNPage(10); const p4 = try alloc.allocNPage(10); @as(*volatile u8, @ptrCast(p1)).* = 10; @as(*volatile u8, @ptrCast(p2)).* = 10; @as(*volatile u8, @ptrCast(p3)).* = 10; @as(*volatile u8, @ptrCast(p4)).* = 10; const p5 = try alloc.allocNPage(10); @as(*volatile u8, @ptrCast(p5)).* = 10; try alloc.freeNPage(p2, 10); const p6 = try alloc.allocNPage(10); try alloc.freeNPage(p1, 10); try alloc.freeNPage(p3, 10); try alloc.freeNPage(p4, 10); try alloc.freeNPage(p5, 10); try alloc.freeNPage(p6, 10); kprint("[kTEST] userspace page alloc test successfull \n", .{}); } pub fn testUserSpaceMem(addr: usize) void { @as(*usize, @ptrFromInt(addr)).* = 100; if (@as(*usize, @ptrFromInt(addr)).* == 100) kprint("[kTEST] write to userspace successfull \n", .{}); } pub fn testKMalloc(alloc: anytype) !void { const alloced_obj = try alloc.alloc(usize, 10, null); alloced_obj[1] = 100; alloced_obj[9] = 900; const alloced_obj2 = try alloc.alloc(usize, 102, null); try alloc.free(alloced_obj); alloced_obj2[33] = 3; try alloc.free(alloced_obj2); const alloced_obj3 = try alloc.alloc(u8, 102400 * 1.5, null); alloced_obj3[30] = 0xff; const alloced_obj4 = try alloc.alloc(u8, 102400 * 1.5, null); alloced_obj4[30] = 0xff; const alloced_obj5 = try alloc.alloc(u8, 102400 * 1.5, null); alloced_obj5[30] = 0xff; try alloc.free(alloced_obj4); const alloced_obj6 = try alloc.alloc(u8, 102400 * 1.5, null); alloced_obj6[30] = 0xff; try alloc.free(alloced_obj5); try alloc.free(alloced_obj3); try alloc.free(alloced_obj6); kprint("[kTEST] kernel alloc test successfull \n", .{}); }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/linker.ld
ENTRY(kernel_main) SECTIONS { # exaplatnation as to why this exact address can be found in the readme under mmu . = {@zig}; .text : ALIGN(16) { *(.text.kernel_main); } .exceptions : ALIGN(0x800) { *(.text.exc_vec); } .kernel : ALIGN(16) { *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(16) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .kernel_space (NOLOAD) : ALIGN(8) { _kernel_space_start = .; } }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/sysCalls.zig
const std = @import("std"); const periph = @import("periph"); const pl011 = periph.Pl011(.ttbr1); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const utils = @import("utils"); const board = @import("board"); const arm = @import("arm"); const CpuContext = arm.cpuContext.CpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const k_utils = @import("utils.zig"); const sharedKernelServices = @import("sharedKernelServices"); const StatusControl = sharedKernelServices.StatusControl; const Scheduler = sharedKernelServices.Scheduler; const Topics = sharedKernelServices.SysCallsTopicsInterface; const Semaphore = sharedKernelServices.KSemaphore; // global user required since the scheduler calls are invoked via svc extern var scheduler: *Scheduler; extern var status_control: *StatusControl; extern var topics: *Topics; pub const Syscall = struct { id: u32, //x0..x7 = parameters and arguments (if x0 is negative it's an errno) //x8 = SysCall id fn_call: *const fn (params_args: *CpuContext) void, }; pub const sysCallTable = [_]Syscall{ .{ .id = 0, .fn_call = &sysCallPrint }, .{ .id = 1, .fn_call = &killTask }, // .{ .id = 2, .fn_call = &xxx }, .{ .id = 3, .fn_call = &getPid }, .{ .id = 4, .fn_call = &killTaskRecursively }, // .{ .id = 5, .fn_call = &xxx }, .{ .id = 6, .fn_call = &createThread }, .{ .id = 7, .fn_call = &sleep }, .{ .id = 8, .fn_call = &haltProcess }, .{ .id = 9, .fn_call = &continueProcess }, // .{ .id = 10, .fn_call = &xxx }, // .{ .id = 11, .fn_call = &xxx }, .{ .id = 12, .fn_call = &pushToTopic }, .{ .id = 13, .fn_call = &popFromTopic }, .{ .id = 14, .fn_call = &waitForTopicUpdate }, .{ .id = 15, .fn_call = &increaseCurrTaskPreemptCounter }, .{ .id = 16, .fn_call = &decreaseCurrTaskPreemptCounter }, .{ .id = 17, .fn_call = &updateStatus }, .{ .id = 18, .fn_call = &readStatus }, }; fn sysCallPrint(params_args: *CpuContext) void { // arguments for the function from the saved interrupt context const data = params_args.x0; const len = params_args.x1; var sliced_data: []u8 = undefined; sliced_data.len = len; sliced_data.ptr = @as([*]u8, @ptrFromInt(data)); pl011.write(sliced_data); } fn killTask(params_args: *CpuContext) void { kprint("[kernel] killing task with pid: {d} \n", .{params_args.x0}); scheduler.killTask(@as(u16, @truncate(params_args.x0))) catch |e| { kprint("[panic] killTask error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } // kill a process and all its children processes fn killTaskRecursively(params_args: *CpuContext) void { kprint("[kernel] killing task and children starting with pid: {d} \n", .{params_args.x0}); scheduler.killTaskAndChildrend(@as(u16, @truncate(params_args.x0))) catch |e| { kprint("[panic] killTaskRecursively error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } // fn forkProcess(params_args: *CpuContext) void { // kprint("[kernel] forking task with pid: {d} \n", .{params_args.x0}); // scheduler.deepForkProcess(params_args.x0) catch |e| { // kprint("[panic] deepForkProcess error: {s}\n", .{@errorName(e)}); // k_utils.panic(); // }; // } fn getPid(params_args: *CpuContext) void { params_args.x0 = scheduler.getCurrentProcessPid(); } fn createThread(params_args: *CpuContext) void { const entry_fn_ptr = @as(*anyopaque, @ptrFromInt(params_args.x0)); const thread_stack = params_args.x1; const args = @as(*anyopaque, @ptrFromInt(params_args.x2)); const thread_fn_ptr = @as(*anyopaque, @ptrFromInt(params_args.x3)); scheduler.createThreadFromCurrentProcess(entry_fn_ptr, thread_fn_ptr, thread_stack, args) catch |e| { kprint("[panic] createThreadFromCurrentProcess error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn sleep(params_args: *CpuContext) void { const delay_in_sched_inter = params_args.x0; scheduler.setProcessAsleep(scheduler.getCurrentProcessPid(), delay_in_sched_inter, params_args) catch |e| { kprint("[panic] setProcessAsleep error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn haltProcess(params_args: *CpuContext) void { const pid: u16 = @as(u16, @truncate(params_args.x0)); scheduler.setProcessState(pid, .halted, params_args) catch |e| { kprint("Scheduler setProcessState err: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn continueProcess(params_args: *CpuContext) void { const pid: u16 = @as(u16, @truncate(params_args.x0)); scheduler.setProcessState(pid, .running, params_args) catch |e| { kprint("Scheduler setProcessState err: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn increaseCurrTaskPreemptCounter(params_args: *CpuContext) void { _ = params_args; scheduler.current_task.preempt_count += 1; } fn decreaseCurrTaskPreemptCounter(params_args: *CpuContext) void { _ = params_args; scheduler.current_task.preempt_count -= 1; } fn pushToTopic(params_args: *CpuContext) void { const id = params_args.x0; const data_ptr = params_args.x1; const data_len = params_args.x2; // kprint("...: {any}\n", .{params_args.x0}); params_args.x0 = topics.write(id, @as(*u8, @ptrFromInt(data_ptr)), data_len) catch |e| { kprint("Topics write error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn popFromTopic(params_args: *CpuContext) void { const id = params_args.x0; const data_len = params_args.x1; var ret_buff: []u8 = undefined; ret_buff.ptr = @ptrFromInt(params_args.x2); ret_buff.len = data_len; params_args.x0 = topics.read(id, ret_buff) catch |e| { kprint("Topics popFromTopic error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn waitForTopicUpdate(params_args: *CpuContext) void { const topic_id = params_args.x0; const pid: u16 = @as(u16, @truncate(params_args.x1)); topics.makeTaskWait(topic_id, pid, params_args) catch |e| { kprint("Topics waitForTopicUpdate error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn updateStatus(params_args: *CpuContext) void { const status_id = @as(u16, @intCast(params_args.x0)); const val_addr = params_args.x1; status_control.updateStatusRaw(status_id, val_addr) catch |e| { kprint("StatusControl updateStatus error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; } fn readStatus(params_args: *CpuContext) void { const status_id = @as(u16, @intCast(params_args.x0)); const ret_buff = params_args.x1; status_control.readStatusRaw(status_id, ret_buff) catch |e| { kprint("StatusControl readRaw error: {s}\n", .{@errorName(e)}); @as(*isize, @ptrCast(&params_args.x0)).* = 0 - @as(isize, @intCast(@intFromError(e))); return; }; }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/kernel.zig
const std = @import("std"); const utils = @import("utils"); const board = @import("board"); const kernelThreads = @import("kernelThreads"); const setupRoutines = @import("setupRoutines"); // kernel services const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const SysCallsTopicsInterface = sharedKernelServices.SysCallsTopicsInterface; const StatusControl = sharedKernelServices.StatusControl; // KernelAllocator and UserPageAllocator types are inited in sharedKernelServices!. const KernelAllocator = sharedKernelServices.KernelAllocator; const UserPageAllocator = sharedKernelServices.UserPageAllocator; const k_utils = @import("utils.zig"); const tests = @import("tests.zig"); const intHandle = @import("kernelIntHandler.zig"); const sysCalls = @import("sysCalls.zig"); const b_options = @import("build_options"); const kpi = @import("kpi"); const alignForward = std.mem.alignForward; // arm specific periphs const arm = @import("arm"); const ProccessorRegMap = arm.processor.ProccessorRegMap; const mmu = arm.mmu; // general peripherals const periph = @import("periph"); // pre_kernel_page_table_init_kprint... // uses userspace addresses(ttbr0), since those are still identity mapped // to access peripherals const old_mapping_kprint = periph.uart.UartWriter(.ttbr0).kprint; const kprint = periph.uart.UartWriter(.ttbr1).kprint; // raspberry specific periphs // const bcm2835IntController = arm.bcm2835IntController.InterruptController(.ttbr1); var user_page_alloc = UserPageAllocator.init() catch |e| { @compileError(@errorName(e)); }; // pointer is now global, ! kernel main lifetime needs to be equal to schedulers lt.. ! export var scheduler: *Scheduler = undefined; export var status_control: *StatusControl = undefined; export var topics: *SysCallsTopicsInterface = undefined; const apps = blk: { var apps_addresses = [_][]const u8{undefined} ** b_options.apps.len; for (b_options.apps, 0..) |app, i| { const app_file = @embedFile("bins/apps/" ++ app); apps_addresses[i] = app_file; } break :blk apps_addresses; }; const actions = blk: { var action_addresses = [_][]const u8{undefined} ** b_options.actions.len; for (b_options.actions, 0..) |action, i| { const app_file = @embedFile("bins/actions/" ++ action); action_addresses[i] = app_file; } break :blk action_addresses; }; // todo => add error handling such that try can be used in such "main" funcitons export fn kernel_main(boot_without_rom_new_kernel_loc: usize) linksection(".text.kernel_main") callconv(.C) noreturn { // !! kernel sp is set in the Bootloader!! { const _exc_vec_label: usize = @intFromPtr(@extern(?*u8, .{ .name = "_exception_vector_table" }) orelse { kprint("[panic] error reading _exception_vector_table label\n", .{}); k_utils.panic(); }); ProccessorRegMap.setExceptionVec(_exc_vec_label); } // required for every page table modification, since the absolute memory location needs to be given to the mmu const kernel_lma_offset = boot_without_rom_new_kernel_loc + board.config.mem.ram_start_addr; const _kernel_space_start: usize = @intFromPtr(@extern(?*u8, .{ .name = "_kernel_space_start" }) orelse { old_mapping_kprint("[panic] error reading _kernel_space_start label\n", .{}); k_utils.panic(); }); var kspace_alloc = KernelAllocator.init(std.mem.alignForward(usize, _kernel_space_start, 8) + board.config.mem.k_stack_size) catch |e| { old_mapping_kprint("[panic] KernelAllocator init error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; // mmu config block { const ttbr1 = blk: { const page_table = mmu.PageTable(board.config.mem.va_kernel_space_page_table_capacity, board.config.mem.va_kernel_space_gran) catch |e| { old_mapping_kprint("[panic] Page table init error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; const ttbr1_mem = @as(*volatile [page_table.totaPageTableSize]usize, @ptrCast((kspace_alloc.alloc(usize, page_table.totaPageTableSize, board.config.mem.va_kernel_space_gran.page_size) catch |e| { old_mapping_kprint("[panic] Page table kalloc error: {s}\n", .{@errorName(e)}); k_utils.panic(); }).ptr)); // mapping general kernel mem (inlcuding device base) var ttbr1_write = page_table.init(ttbr1_mem, kernel_lma_offset) catch |e| { old_mapping_kprint("[panic] Page table init error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; { // creating virtual address space for kernel const kernel_space_mapping = mmu.Mapping{ .mem_size = board.config.mem.kernel_space_size, .pointing_addr_start = kernel_lma_offset, .virt_addr_start = 0, .granule = board.config.mem.va_kernel_space_gran, .addr_space = .ttbr1, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write }, }; ttbr1_write.mapMem(kernel_space_mapping) catch |e| { old_mapping_kprint("[panic] Page table write error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; } { // creating virtual address space for periphs const periph_mapping = mmu.Mapping{ .mem_size = board.PeriphConfig(.ttbr0).device_base_size, .pointing_addr_start = board.PeriphConfig(.ttbr0).device_base, .virt_addr_start = board.PeriphConfig(.ttbr0).new_ttbr1_device_base, .granule = board.config.mem.va_kernel_space_gran, .addr_space = .ttbr1, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write }, }; ttbr1_write.mapMem(periph_mapping) catch |e| { old_mapping_kprint("[panic] Page table write error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; } break :blk ttbr1_mem; }; const ttbr0 = blk: { const page_table = mmu.PageTable(board.config.mem.va_user_space_page_table_capacity, board.config.mem.va_user_space_gran) catch |e| { @compileError(@errorName(e)); }; const ttbr0_mem = @as(*volatile [page_table.totaPageTableSize]usize, @ptrCast((kspace_alloc.alloc(usize, page_table.totaPageTableSize, board.config.mem.va_user_space_gran.page_size) catch |e| { old_mapping_kprint("[panic] sPage table kalloc error: {s}\n", .{@errorName(e)}); k_utils.panic(); }).ptr)); // MMU page dir config var page_table_write = page_table.init(ttbr0_mem, kernel_lma_offset) catch |e| { old_mapping_kprint("[panic] Page table init error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; const user_space_mapping = mmu.Mapping{ .mem_size = board.config.mem.user_space_size, .pointing_addr_start = kernel_lma_offset + board.config.mem.kernel_space_size, .virt_addr_start = 0, .granule = board.config.mem.va_user_space_gran, .addr_space = .ttbr0, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .only_el1_read_write }, }; page_table_write.mapMem(user_space_mapping) catch |e| { old_mapping_kprint("[panic] Page table write error: {s}\n", .{@errorName(e)}); k_utils.panic(); }; break :blk ttbr0_mem; }; ProccessorRegMap.TcrReg.setTcrEl(.el1, (ProccessorRegMap.TcrReg{ .t0sz = 25, .t1sz = 25, .tg0 = 0, .tg1 = 0 }).asInt()); ProccessorRegMap.MairReg.setMairEl(.el1, (ProccessorRegMap.MairReg{ .attr0 = 0xFF, .attr1 = 0x0, .attr2 = 0x0, .attr3 = 0x0, .attr4 = 0x0 }).asInt()); ProccessorRegMap.dsb(); ProccessorRegMap.isb(); ProccessorRegMap.invalidateOldPageTableEntries(); // ProccessorRegMap.invalidateMmuTlbEl1(); ProccessorRegMap.invalidateCache(); // updating page dirs for kernel and user space // toUnsec is bc we are in ttbr1 and can't change with page tables that are also in ttbr1 ProccessorRegMap.setTTBR1(kernel_lma_offset + utils.toTtbr0(usize, @intFromPtr(ttbr1))); ProccessorRegMap.setTTBR0(kernel_lma_offset + utils.toTtbr0(usize, @intFromPtr(ttbr0))); ProccessorRegMap.dsb(); ProccessorRegMap.isb(); ProccessorRegMap.nop(); ProccessorRegMap.nop(); } kprint("[kernel] page tables updated! \n", .{}); const current_el = ProccessorRegMap.getCurrentEl(); if (current_el != 1) { kprint("[panic] el must be 1! (it is: {d})\n", .{current_el}); ProccessorRegMap.panic(); } kprint("[kernel] kernel boot complete \n", .{}); tests.testUserPageAlloc(&user_page_alloc) catch |e| { kprint("[panic] testUserPageAlloc test error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; var scheduler_tmp = Scheduler.init(&user_page_alloc, kernel_lma_offset); scheduler = &scheduler_tmp; { var topics_tmp = SysCallsTopicsInterface.init(&user_page_alloc, scheduler) catch |e| { kprint("[panic] SysCallsTopicsInterface init error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; topics = &topics_tmp; } { var status_control_tmp = StatusControl.init(&kspace_alloc) catch |e| { kprint("[panic] StatusControl init error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; status_control = &status_control_tmp; } { kprint("[kernel] starting scheduler \n", .{}); // boot process = this process scheduler.configRootBootProcess(); scheduler.initAppsInScheduler(&apps, topics.mem_pool) catch |e| { kprint("[panic] Scheduler initAppsInScheduler error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; // scheduler.initActionsInScheduler(&actions, topics.mem_pool) catch |e| { // kprint("[panic] actions init error: {s} \n", .{@errorName(e)}); // k_utils.panic(); // }; scheduler.initProcessCounter(); } // kernel setup routines execution inline for (setupRoutines.setupRoutines) |routine| { routine(scheduler); } board.driver.timerDriver.initTimerDriver() catch |e| { kprint("[panic] timer driver error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; kprint("[kernel] timer inited \n", .{}); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.initIcDriver() catch |e| { kprint("[panic] initIcDriver error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; } // kernel thread scheduler init inline for (kernelThreads.threads) |generic_thread| { scheduler.createKernelThread(&kspace_alloc, generic_thread, .{scheduler}) catch |e| { kprint("[panic] kernel thread createKernelThread error: {s} \n", .{@errorName(e)}); k_utils.panic(); }; } var counter: usize = 0; while (true) { kprint("while counter: {d} \n", .{counter}); // kprint("timer: {d} irq: {d} \n", .{ bcm2835Timer.RegMap.timerCs.*, bcm2835IntController.RegMap.enableIrq1.* }); counter += 1; } } comptime { @export(intHandle.trapHandler, .{ .name = "trapHandler", .linkage = .Strong }); }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/kernel/exc_vec.S
.section .text.exc_vec // https://developer.arm.com/documentation/100933/0100/AArch64-exception-vector-table .globl _exception_vector_table .balign 0x80 _exception_vector_table: b _el1Sp0Sync // el1_sp0_sync .balign 0x80 b _el1Sp0Irq // el1_sp0_irq .balign 0x80 b _el1Sp0Fiq // el1_sp0_fiq .balign 0x80 b el1Sp0Err // el1_sp0_error .balign 0x80 b _el1Sync // el1Sync .balign 0x80 b _el1Irq // el1Irq .balign 0x80 b _el1Fiq // el1Fiq .balign 0x80 b _el1Err // el1Error .balign 0x80 b _el0Sync // el0_sync .balign 0x80 b _el0Irq // el0_irq .balign 0x80 b _el0Fiq // el0_fiq .balign 0x80 b _el0Err // el0_error .balign 0x80 b _el032Sync // el0_32_sync .balign 0x80 b _el032Irq // el0_32_irq .balign 0x80 b _el032Fiq // el0_32_fiq .balign 0x80 b _el032Err // el0_32_error .balign 0x80 .macro SAVE_CPU_CONTEXT // storing CpuContext struct(src/arm/CpuContext.zig) on stack stp q1, q0, [sp, #-32]! stp q3, q2, [sp, #-32]! stp q5, q4, [sp, #-32]! stp q7, q6, [sp, #-32]! stp q9, q8, [sp, #-32]! stp q11, q10, [sp, #-32]! stp q13, q12, [sp, #-32]! stp q15, q14, [sp, #-32]! stp q17, q16, [sp, #-32]! stp q19, q18, [sp, #-32]! stp q21, q20, [sp, #-32]! stp q23, q22, [sp, #-32]! stp q25, q24, [sp, #-32]! stp q27, q26, [sp, #-32]! stp q29, q28, [sp, #-32]! stp q31, q30, [sp, #-32]! // gp regs stp x1, x0, [sp, #-16]! stp x3, x2, [sp, #-16]! stp x5, x4, [sp, #-16]! stp x7, x6, [sp, #-16]! stp x9, x8, [sp, #-16]! stp x11, x10, [sp, #-16]! stp x13, x12, [sp, #-16]! stp x15, x14, [sp, #-16]! stp x17, x16, [sp, #-16]! stp x19, x18, [sp, #-16]! stp x21, x20, [sp, #-16]! stp x23, x22, [sp, #-16]! stp x25, x24, [sp, #-16]! stp x27, x26, [sp, #-16]! stp x29, x28, [sp, #-16]! // sys regs mov x1, sp add x1, x1, #752 stp x1, x30, [sp, #-16]! mov x0, fp mrs x3, elr_el1 stp x3, x0, [sp, #-16]! mrs x0, sp_el0 // debug regs mrs x3, SPSel stp x3, x0, [sp, #-16]! mrs x0, far_el1 mrs x3, esr_el1 stp x0, x3, [sp, #-16]! mrs x0, CurrentEL lsr x0, x0, #2 stp xzr, x0, [sp, #-16]! .endm .macro EXCEPTION_VECTOR int_type SAVE_CPU_CONTEXT // bl disableIrq // set stack as arg ldr x1, #\int_type mov x0, sp bl trapHandler // bl enableIrq // restoreContextFromStack are fns exported from CpuContext.zig b _restoreContextWithoutSwitchFromSp .endm _el1Sp0Sync: EXCEPTION_VECTOR el1Sp0Sync _el1Sp0Irq: EXCEPTION_VECTOR el1Sp0Irq _el1Sp0Fiq: EXCEPTION_VECTOR el1Sp0Fiq _el1Sp0Err: EXCEPTION_VECTOR el1Sp0Err _el1Sync: EXCEPTION_VECTOR el1Sync _el1Irq: EXCEPTION_VECTOR el1Irq _el1Fiq: EXCEPTION_VECTOR el1Fiq _el1Err: EXCEPTION_VECTOR el1Err _el0Sync: EXCEPTION_VECTOR el0Sync _el0Irq: EXCEPTION_VECTOR el0Irq _el0Fiq: EXCEPTION_VECTOR el0Fiq _el0Err: EXCEPTION_VECTOR el0Err _el032Sync: EXCEPTION_VECTOR el032Sync _el032Irq: EXCEPTION_VECTOR el032Irq _el032Fiq: EXCEPTION_VECTOR el032Fiq _el032Err: EXCEPTION_VECTOR el032Err
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/SysCallsTopicsInterface.zig
const std = @import("std"); const utils = @import("utils"); const board = @import("board"); const env = @import("environment"); const TopicBufferTypes = env.envConfTemplate.EnvConfig.TopicBufferTypes; const ProccessorRegMap = arm.processor.ProccessorRegMap; const kprint = @import("periph").uart.UartWriter(.ttbr1).kprint; const UserPageAllocator = @import("UserPageAllocator.zig").UserPageAllocator; const Scheduler = @import("Scheduler.zig").Scheduler; const arm = @import("arm"); const KSemaphore = @import("KSemaphore.zig").Semaphore; const CpuContext = arm.cpuContext.CpuContext; const Topic = @import("sharedServices").Topic(KSemaphore(1)); const alignForward = std.mem.alignForward; pub const SysCallsTopicsInterface = struct { const Error = error{ TopicIdNotFound, }; topics: [env.env_config.countTopics()]Topic, mem_pool: []u8, scheduler: *Scheduler, pub fn init(user_page_alloc: *UserPageAllocator, scheduler: *Scheduler) !SysCallsTopicsInterface { var accumulatedTopicsBuffSize: usize = 0; for (&env.env_config.status_control) |*status_control_conf| { if (status_control_conf.*.status_type == .topic) { accumulatedTopicsBuffSize += status_control_conf.topic_conf.?.buffer_size + @sizeOf(usize); } } const pages_req = (try std.math.mod(usize, accumulatedTopicsBuffSize, board.config.mem.va_user_space_gran.page_size)) + 1; const topics_mem = try user_page_alloc.allocNPage(pages_req); var topics = [_]Topic{undefined} ** env.env_config.countTopics(); var used_topics_mem: usize = 0; var i: usize = 0; for (&env.env_config.status_control) |*status_control_conf| { if (status_control_conf.*.status_type == .topic) { const topic_read_write_buff_ptr = @as(*volatile usize, @ptrFromInt(used_topics_mem)); topic_read_write_buff_ptr.* = 0; topics[i] = Topic.init(topics_mem[used_topics_mem + @sizeOf(usize) .. used_topics_mem + status_control_conf.topic_conf.?.buffer_size], topic_read_write_buff_ptr, status_control_conf.id, status_control_conf.topic_conf.?.buffer_type); used_topics_mem += status_control_conf.topic_conf.?.buffer_size; i += 1; } } return .{ .topics = topics, .mem_pool = topics_mem, .scheduler = scheduler, }; } pub fn write(self: *SysCallsTopicsInterface, id: usize, data_ptr: *u8, len: usize) !usize { // switching to boot userspace page table (which spans all apps in order to acces other apps memory with their relative userspace addresses...) self.scheduler.switchMemContext(self.scheduler.scheduled_tasks[0].ttbr0.?, null); defer self.scheduler.switchMemContext(self.scheduler.current_task.ttbr0.?, null); const userspace_app_mapping_data_addr = @intFromPtr(self.scheduler.current_task.app_mem.?.ptr) + @intFromPtr(data_ptr); if (self.findTopicById(id)) |index| { var data: []u8 = undefined; data.ptr = @as([*]u8, @ptrFromInt(userspace_app_mapping_data_addr)); data.len = len; const data_written: usize = try self.topics[index].write(data); for (&self.topics[index].waiting_tasks) |*semaphore| { if (semaphore.* != null) { try semaphore.*.?.signal(self.scheduler); semaphore.* = null; self.topics[index].n_waiting_taks -= 1; } } return data_written; } else return Error.TopicIdNotFound; } pub fn read(self: *SysCallsTopicsInterface, id: usize, ret_buff: []u8) !usize { // switching to boot userspace page table (which spans all apps in order to acces other apps memory with their relative userspace addresses...) self.scheduler.switchMemContext(self.scheduler.scheduled_tasks[0].ttbr0.?, null); defer self.scheduler.switchMemContext(self.scheduler.current_task.ttbr0.?, null); var userspace_app_mapping_ret_buff: []u8 = undefined; userspace_app_mapping_ret_buff.ptr = @ptrFromInt(@intFromPtr(self.scheduler.current_task.app_mem.?.ptr) + @intFromPtr(ret_buff.ptr)); userspace_app_mapping_ret_buff.len = ret_buff.len; if (self.findTopicById(id)) |index| { return self.topics[index].read(userspace_app_mapping_ret_buff); } else return Error.TopicIdNotFound; } pub fn makeTaskWait(self: *SysCallsTopicsInterface, topic_id: usize, pid: u16, irq_context: *CpuContext) !void { if (self.findTopicById(topic_id)) |index| { if (self.topics[index].n_waiting_taks > self.topics[index].waiting_tasks.len) { kprint("[panic] Topic maxWaitingTasks exceeded \n", .{}); while (true) {} } // is increased before Semaphore wait call because that may invoke the scheduler which would thus not increase the counter self.topics[index].n_waiting_taks += 1; self.topics[index].waiting_tasks[self.topics[index].n_waiting_taks - 1] = KSemaphore(1).init(1); try self.topics[index].waiting_tasks[self.topics[index].n_waiting_taks - 1].?.wait(pid, self.scheduler, irq_context); } } // returns index fn findTopicById(self: *SysCallsTopicsInterface, id: usize) ?usize { for (&self.topics, 0..) |*topic, i| { if (topic.id == id) return i; } return null; } };
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/Scheduler.zig
const std = @import("std"); const alignForward = std.mem.alignForward; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const board = @import("board"); const utils = @import("utils"); const b_options = @import("build_options"); const arm = @import("arm"); const mmu = arm.mmu; const KernelAlloc = @import("KernelAllocator.zig").KernelAllocator; const Topics = @import("SysCallsTopicsInterface.zig").SysCallsTopicsInterface; const ProccessorRegMap = arm.processor.ProccessorRegMap; const CpuContext = arm.cpuContext.CpuContext; const UserPageAllocator = @import("UserPageAllocator.zig").UserPageAllocator; const app_page_table = mmu.PageTable(board.config.mem.app_vm_mem_size, board.config.mem.va_user_space_gran) catch |e| { @compileError(@errorName(e)); }; const kernel_page_table = mmu.PageTable(board.config.mem.app_vm_mem_size, board.config.mem.va_kernel_space_gran) catch |e| { @compileError(@errorName(e)); }; const log = true; pub const Task = struct { pub const TaskState = enum(usize) { running, halted, sleeping, dead, }; pub const PrivLevel = enum(usize) { // initial task that comes up after the bootloader boot, // root level user type kernel, // userspace level user, }; pub const TaskType = enum(usize) { process, thread, action, }; cpu_context: CpuContext, task_type: TaskType, sleep_counter: usize, priv_level: PrivLevel, state: TaskState, counter: isize, priority: isize, pid: ?u16, parent_pid: ?u16, child_pid: ?u16, preempt_count: isize, page_table: [app_page_table.totaPageTableSize]usize align(4096), app_mem: ?[]u8, ttbr1: ?usize, ttbr0: ?usize, pub fn init() Task { return Task{ .cpu_context = CpuContext.init(), .task_type = .process, .priv_level = .user, .state = .dead, .counter = 0, .sleep_counter = 0, .pid = null, .parent_pid = null, .child_pid = null, .priority = 1, .preempt_count = 0, .page_table = [_]usize{0} ** app_page_table.totaPageTableSize, .app_mem = null, .ttbr1 = null, .ttbr0 = null, }; } }; pub const Error = error{ PidNotFound, TaskIsDead, ForkPermissionFault, ThreadPermissionFault, CannotKillAction, }; const maxProcesss = 10; const maxActions = 1; var env_processes = [_]Task{Task.init()} ** maxProcesss; pub const Scheduler = struct { page_allocator: *UserPageAllocator, kernel_lma_offset: usize, scheduled_tasks: *[maxProcesss]Task, tasks_sleeping: [maxProcesss]?*Task, env_actions: [1]Task, current_task: *Task, pid_counter: u16, pub fn init(page_allocator: *UserPageAllocator, kernel_lma_offset: usize) Scheduler { return .{ .page_allocator = page_allocator, .kernel_lma_offset = kernel_lma_offset, .tasks_sleeping = [_]?*Task{null} ** maxProcesss, .scheduled_tasks = &env_processes, .env_actions = [_]Task{Task.init()} ** 1, .current_task = &env_processes[0], .pid_counter = 0, }; } pub fn configRootBootProcess(self: *Scheduler) void { // the init process contains all relevant mem&cpu context information of the "main" kernel process // and as such has the highest priority self.current_task.priority = 15; self.current_task.priv_level = .boot; self.current_task.state = .running; self.current_task.pid = 0; var app_mem: []u8 = undefined; app_mem.ptr = @as([*]u8, @ptrFromInt(board.config.mem.va_start)); app_mem.len = board.config.mem.kernel_space_size; self.current_task.app_mem = app_mem; self.current_task.ttbr0 = ProccessorRegMap.readTTBR0(); self.current_task.ttbr1 = ProccessorRegMap.readTTBR1(); self.pid_counter += 1; } // assumes that all process counter were inited to 0 pub fn initProcessCounter(self: *Scheduler) void { for (self.scheduled_tasks) |*process| { process.counter = (process.counter >> 1) + process.priority; } } pub fn schedule(self: *Scheduler, irq_context: ?*CpuContext) void { self.current_task.preempt_count += 1; errdefer self.current_task.preempt_count -= 1; self.current_task.counter = 0; // round robin for processes var next_proc_index: usize = 0; var c: isize = -1; while (true) { for (self.scheduled_tasks, 0..) |*process, i| { if (i >= self.pid_counter) break; if (process.state == .running and process.counter > c) { c = process.counter; next_proc_index = i; } } if (c != 0) break; for (self.scheduled_tasks, 0..) |*process, i| { if (i >= self.pid_counter) break; process.counter = (process.counter >> 1) + process.priority; } } self.current_task.preempt_count -= 1; self.switchContextToProcess(&self.scheduled_tasks[next_proc_index], irq_context); } pub fn timerIntEvent(self: *Scheduler, irq_context: *CpuContext) void { self.current_task.counter -= 1; for (self.tasks_sleeping, 0..) |proc, i| { if (proc) |process| { if (process.sleep_counter <= 0) { process.state = .running; self.tasks_sleeping[i] = null; } else { process.sleep_counter -= 1; } } } if (self.current_task.counter > 0 or self.current_task.preempt_count > 0) { if (self.current_task.counter <= 0) kprint("self.current_task.preempt_count: {d} \n", .{self.current_task.preempt_count}); if (log) kprint("--------- PROC WAIT counter: {d} \n", .{self.current_task.counter}); // return all the way back to the exc vector table where cpu state is restored from the stack // if the task is dead already, we don't return back to the process but schedule the next task if (self.current_task.state == .running) return; } self.schedule(irq_context); } pub fn initAppsInScheduler(self: *Scheduler, apps: []const []const u8, topics_mem_pool: []u8) !void { self.current_task.preempt_count += 1; defer self.current_task.preempt_count -= 1; for (apps, 0..) |app, j| { const i = j + 1; // skip root task (index 0) const req_pages = try std.math.divCeil(usize, board.config.mem.app_vm_mem_size, board.config.mem.va_user_space_gran.page_size); const app_mem = try self.page_allocator.allocNPage(req_pages); std.mem.copy(u8, app_mem, app); self.scheduled_tasks[i].cpu_context.elr_el1 = 0; self.scheduled_tasks[i].cpu_context.sp_el0 = alignForward(usize, app.len + board.config.mem.app_stack_size, 16); self.scheduled_tasks[i].cpu_context.x0 = self.pid_counter; self.scheduled_tasks[i].app_mem = app_mem; self.scheduled_tasks[i].priority = self.current_task.priority; self.scheduled_tasks[i].state = .running; self.scheduled_tasks[i].priv_level = .user; self.scheduled_tasks[i].counter = self.scheduled_tasks[i].priority; self.scheduled_tasks[i].preempt_count = 0; self.scheduled_tasks[i].pid = self.pid_counter; // initing the apps page-table { // MMU page dir config var page_table_write = try app_page_table.init(&self.scheduled_tasks[i].page_table, self.kernel_lma_offset); const user_space_mapping = mmu.Mapping{ .mem_size = board.config.mem.app_vm_mem_size, .pointing_addr_start = self.kernel_lma_offset + board.config.mem.kernel_space_size + @intFromPtr(app_mem.ptr), .virt_addr_start = 0, .granule = board.boardConfig.Granule.Fourk, .addr_space = .ttbr0, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write }, }; try page_table_write.mapMem(user_space_mapping); } // initing the apps topics-interface { // MMU page dir config var page_table_write = try app_page_table.init(&self.scheduled_tasks[i].page_table, self.kernel_lma_offset); const topics_interace_mapping = mmu.Mapping{ .mem_size = topics_mem_pool.len, .pointing_addr_start = self.kernel_lma_offset + board.config.mem.kernel_space_size + @intFromPtr(topics_mem_pool.ptr), .virt_addr_start = 0x20000000, .granule = board.boardConfig.Granule.Fourk, .addr_space = .ttbr0, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write }, }; try page_table_write.mapMem(topics_interace_mapping); } self.scheduled_tasks[i].ttbr0 = self.kernel_lma_offset + utils.toTtbr0(usize, @intFromPtr(&self.scheduled_tasks[i].page_table)); self.pid_counter += 1; } } pub fn killTask(self: *Scheduler, pid: u16) !void { self.current_task.preempt_count += 1; errdefer self.current_task.preempt_count -= 1; _ = try self.checkForPid(pid); const pid_info = try self.findTaskByPid(pid); if (pid_info.task_type == .action) return Error.CannotKillAction; self.scheduled_tasks[pid_info.index].state = .dead; for (self.scheduled_tasks) |*proc| { if (proc.task_type == .thread and proc.parent_pid == pid) { proc.state = .dead; } } self.current_task.preempt_count -= 1; self.schedule(null); } pub fn exitTask(self: *Scheduler) !noreturn { try self.killTaskAndChildrend(self.current_task.pid.?); while (true) {} } // function is deprecated since new tasks cannot be created without allocating new memory which is not legal in system runtime // todo => find way around policy pub fn deepForkProcess(self: *Scheduler, to_clone_pid: u16) !void { self.current_task.preempt_count += 1; defer { self.current_task.preempt_count -= 1; self.switchMemContext(self.current_task.ttbr0.?, null); } // switching to boot userspace page table (which spans all apps in order to acces other apps memory with their relative userspace addresses...) self.switchMemContext(self.scheduled_tasks[0].ttbr0.?, null); try self.checkForPid(to_clone_pid); if (self.scheduled_tasks[to_clone_pid].priv_level == .boot) return Error.ForkPermissionFault; const req_pages = try std.math.divCeil(usize, board.config.mem.app_vm_mem_size, board.config.mem.va_user_space_gran.page_size); const new_app_mem = try self.page_allocator.allocNPage(req_pages); const new_pid: u16 = self.pid_counter; std.mem.copy(u8, new_app_mem, self.scheduled_tasks[to_clone_pid].app_mem.?); self.scheduled_tasks[new_pid] = self.scheduled_tasks[to_clone_pid]; self.scheduled_tasks[new_pid].app_mem = new_app_mem; self.scheduled_tasks[new_pid].ttbr0 = self.kernel_lma_offset + utils.toTtbr0(usize, @intFromPtr(&self.scheduled_tasks[new_pid].page_table)); self.scheduled_tasks[new_pid].pid = new_pid; self.scheduled_tasks[new_pid].parent_pid = to_clone_pid; self.scheduled_tasks[to_clone_pid].child_pid = new_pid; self.pid_counter += 1; for (&self.scheduled_tasks) |*proc| { if (proc.task_type == .thread or proc.parent_pid == to_clone_pid) { try self.cloneThread(proc.pid.?, new_pid); } } } pub fn cloneThread(self: *Scheduler, to_clone_thread_pid: usize, new_proc_pid: usize) !void { self.current_task.preempt_count += 1; defer self.current_task.preempt_count -= 1; try self.checkForPid(to_clone_thread_pid); if (!self.scheduled_tasks[to_clone_thread_pid].task_type == .thread) return; const new_pid = self.pid_counter; self.scheduled_tasks[new_pid] = self.scheduled_tasks[to_clone_thread_pid]; self.scheduled_tasks[new_pid].pid = new_pid; self.scheduled_tasks[new_pid].parent_pid = new_proc_pid; self.scheduled_tasks[new_pid].ttbr0 = self.scheduled_tasks[new_proc_pid].ttbr0; self.scheduled_tasks[new_pid].ttbr1 = self.scheduled_tasks[new_proc_pid].ttbr1; self.pid_counter += 1; } pub fn createThreadFromCurrentProcess(self: *Scheduler, entry_fn_ptr: *const anyopaque, thread_fn_ptr: *const anyopaque, thread_stack_addr: usize, args: *anyopaque) !void { self.current_task.preempt_count += 1; defer self.current_task.preempt_count -= 1; const curr_task_index = (try self.findTaskByPid(self.current_task.pid.?)).index; const new_pid: u16 = self.pid_counter; self.scheduled_tasks[new_pid].pid = new_pid; self.scheduled_tasks[new_pid].task_type = .thread; self.scheduled_tasks[new_pid].state = self.scheduled_tasks[curr_task_index].state; self.scheduled_tasks[new_pid].counter = self.scheduled_tasks[curr_task_index].priority; self.scheduled_tasks[new_pid].priority = self.scheduled_tasks[curr_task_index].priority; self.scheduled_tasks[new_pid].parent_pid = self.current_task.pid.?; self.scheduled_tasks[new_pid].cpu_context.x0 = @intFromPtr(thread_fn_ptr); self.scheduled_tasks[new_pid].cpu_context.x1 = @intFromPtr(args); self.scheduled_tasks[new_pid].cpu_context.elr_el1 = @intFromPtr(entry_fn_ptr); self.scheduled_tasks[new_pid].cpu_context.sp_el0 = thread_stack_addr; self.scheduled_tasks[new_pid].cpu_context.sp_el1 = thread_stack_addr; self.scheduled_tasks[new_pid].priv_level = self.scheduled_tasks[curr_task_index].priv_level; self.scheduled_tasks[new_pid].ttbr0 = self.scheduled_tasks[curr_task_index].ttbr0; self.scheduled_tasks[new_pid].ttbr1 = self.scheduled_tasks[curr_task_index].ttbr1; self.pid_counter += 1; } // provides a generic entry function (generic in regard to the thread and argument function since @call builtin needs them to properly invoke the thread start) pub fn KernelThreadInstance(comptime thread_fn: anytype, comptime Args: type) type { const ThreadFn = @TypeOf(thread_fn); return struct { pub fn threadEntry(entry_fn: *ThreadFn, entry_args: *Args) callconv(.C) void { @call(.auto, entry_fn, entry_args.*); } }; } // creates thread for current process // info: use only permitted at kernel boot/init pub fn createKernelThread(self: *Scheduler, app_alloc: *KernelAlloc, thread_fn: anytype, args: anytype) !void { const thread_stack_mem = try app_alloc.alloc(u8, board.config.mem.k_stack_size, 16); var thread_stack_start: []u8 = undefined; thread_stack_start.ptr = @as([*]u8, @ptrFromInt(@intFromPtr(thread_stack_mem.ptr) + thread_stack_mem.len)); thread_stack_start.len = thread_stack_mem.len; var arg_mem: []const u8 = undefined; arg_mem.ptr = @as([*]const u8, @ptrCast(@alignCast(&args))); arg_mem.len = @sizeOf(@TypeOf(args)); std.mem.copy(u8, thread_stack_start, arg_mem); const entry_fn = &(KernelThreadInstance(thread_fn, @TypeOf(args)).threadEntry); const thread_fn_ptr = &thread_fn; const thread_stack_addr = @intFromPtr(thread_stack_start.ptr) - alignForward(usize, @sizeOf(@TypeOf(args)), 16); const args_ptr = thread_stack_start.ptr; try self.createThreadFromCurrentProcess(@as(*const anyopaque, @ptrCast(entry_fn)), @as(*const anyopaque, @ptrCast(thread_fn_ptr)), thread_stack_addr, @as(*anyopaque, @ptrCast(args_ptr))); } pub fn ActionInstance(comptime thread_fn: anytype) type { const ThreadFn = @TypeOf(thread_fn); return struct { pub fn actionEntry(entry_fn: *ThreadFn) callconv(.C) void { @call(.auto, entry_fn, .{}); } }; } pub fn initActionsInScheduler(self: *Scheduler, loading_actions: []const []const u8, topics_mem_pool: []u8) !void { // kprint("ss: {any} \n", .{loading_actions}); self.current_task.preempt_count += 1; defer self.current_task.preempt_count -= 1; for (loading_actions, 0..) |action, i| { const req_pages = try std.math.divCeil(usize, board.config.mem.app_vm_mem_size, board.config.mem.va_user_space_gran.page_size); const app_mem = try self.page_allocator.allocNPage(req_pages); std.mem.copy(u8, app_mem, action); self.env_actions[i].cpu_context.elr_el1 = 0; self.env_actions[i].cpu_context.sp_el0 = alignForward(usize, action.len + board.config.mem.app_stack_size, 16); self.env_actions[i].cpu_context.x0 = self.pid_counter; self.env_actions[i].task_type = .action; self.env_actions[i].app_mem = app_mem; self.env_actions[i].priority = self.current_task.priority; self.env_actions[i].state = .halted; self.env_actions[i].priv_level = .user; self.env_actions[i].counter = self.env_actions[i].priority; self.env_actions[i].preempt_count = 0; self.env_actions[i].pid = self.pid_counter; // initing the apps page-table { // MMU page dir config var page_table_write = try app_page_table.init(&self.env_actions[i].page_table, self.kernel_lma_offset); const user_space_mapping = mmu.Mapping{ .mem_size = board.config.mem.app_vm_mem_size, .pointing_addr_start = self.kernel_lma_offset + board.config.mem.kernel_space_size + @intFromPtr(app_mem.ptr), .virt_addr_start = 0, .granule = board.boardConfig.Granule.Fourk, .addr_space = .ttbr0, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write }, }; try page_table_write.mapMem(user_space_mapping); } // initing the apps topics-interface { // MMU page dir config var page_table_write = try app_page_table.init(&self.env_actions[i].page_table, self.kernel_lma_offset); const topics_interace_mapping = mmu.Mapping{ .mem_size = topics_mem_pool.len, .pointing_addr_start = self.kernel_lma_offset + board.config.mem.kernel_space_size + @intFromPtr(topics_mem_pool.ptr), .virt_addr_start = 0x20000000, .granule = board.boardConfig.Granule.Fourk, .addr_space = .ttbr0, .flags_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write, .attrIndex = .mair0 }, .flags_non_last_lvl = mmu.TableDescriptorAttr{ .accessPerm = .read_write }, }; try page_table_write.mapMem(topics_interace_mapping); } self.env_actions[i].ttbr0 = self.kernel_lma_offset + utils.toTtbr0(usize, @intFromPtr(&self.env_actions[i].page_table)); self.pid_counter += 1; } } pub fn killTaskAndChildrend(self: *Scheduler, starting_pid: u16) !void { self.current_task.preempt_count += 1; errdefer self.current_task.preempt_count -= 1; const index = try self.checkForPid(starting_pid); self.scheduled_tasks[index].state = .dead; var child_proc_index: ?u16 = index; while (child_proc_index != null) { self.scheduled_tasks[child_proc_index.?].state = .dead; for (self.scheduled_tasks) |*proc| { if (proc.task_type == .thread and proc.parent_pid == child_proc_index.?) { proc.state = .dead; } } if (self.scheduled_tasks[child_proc_index.?].child_pid) |child_pid| { child_proc_index = (try self.findTaskByPid(child_pid)).index; } else child_proc_index = null; } self.current_task.preempt_count -= 1; self.schedule(null); } pub fn getCurrentProcessPid(self: *Scheduler) u16 { return self.current_task.pid.?; } pub fn setProcessState(self: *Scheduler, pid: u16, state: Task.TaskState, irq_context: ?*CpuContext) !void { const index = (try self.findTaskByPid(pid)).index; self.scheduled_tasks[index].state = state; if (pid == self.current_task.pid and irq_context != null) self.schedule(irq_context.?); } pub fn setProcessAsleep(self: *Scheduler, pid: u16, cycles_sleeping: usize, irq_context: *CpuContext) !void { const index = try self.checkForPid(pid); for (self.tasks_sleeping, 0..) |proc, i| { if (proc == null) { self.tasks_sleeping[i] = &self.scheduled_tasks[index]; } } self.scheduled_tasks[index].sleep_counter = cycles_sleeping; self.scheduled_tasks[index].state = .sleeping; self.schedule(irq_context); } fn checkForPid(self: *Scheduler, pid: u16) !u16 { const index = (try self.findTaskByPid(pid)).index; if (self.scheduled_tasks[index].state == .dead) return Error.TaskIsDead; return index; } // args (process pointers) are past via registers fn switchContextToProcess(self: *Scheduler, next_process: *Task, irq_context: ?*CpuContext) void { const prev_process = self.current_task; self.current_task = next_process; if (next_process.priv_level == .user) self.switchMemContext(next_process.ttbr0, null); switchCpuContext(self, prev_process, next_process, irq_context); } fn switchCpuPrivLvl(priv_level: Task.PrivLevel) void { switch (priv_level) { .user => { ProccessorRegMap.SpsrReg.setSpsrReg(.el1, ProccessorRegMap.SpsrReg.readSpsrReg(.el1) & (~@as(usize, 0b0111))); ProccessorRegMap.setSpsel(.el1); }, .kernel, .boot => { ProccessorRegMap.SpsrReg.setSpsrReg(.el1, ProccessorRegMap.SpsrReg.readSpsrReg(.el1) | 0b0101); ProccessorRegMap.setSpsel(.el0); }, } } // irq_context is optional in case the previous scheduled task is not needed anymore fn switchCpuContext(self: *Scheduler, from: *Task, to: *Task, irq_context: ?*CpuContext) void { kprint("current_procc: {*}, self.current_task.preempt_count: {d} \n", .{ self.current_task, self.current_task.preempt_count }); if (log) { kprint("from: ({s}, {s}, {*}) to ({s}, {s}, {*}) \n", .{ @tagName(from.priv_level), @tagName(from.state), from, @tagName(to.priv_level), @tagName(to.state), to }); kprint("current scheduled_tasks(n={d}): \n", .{self.pid_counter + 1}); for (self.scheduled_tasks, 0..) |*proc, i| { if (i >= self.pid_counter) break; kprint("pid: {d} {s}, {s}, {s}, {any}, {*}\n", .{ i, @tagName(proc.priv_level), @tagName(proc.priv_level), @tagName(proc.state), proc.*.task_type, proc }); } } if (irq_context) |context| from.cpu_context = context.*; switchCpuPrivLvl(to.priv_level); // restore Context and erets asm volatile ( \\ mov sp, %[sp_addr] \\ b _restoreContextFromSp : : [sp_addr] "r" (&to.cpu_context), ); } pub fn switchMemContext(self: *Scheduler, ttbr_0_addr: ?usize, ttbr_1_addr: ?usize) void { _ = self; if (ttbr_0_addr) |addr| ProccessorRegMap.setTTBR0(addr); if (ttbr_1_addr) |addr| ProccessorRegMap.setTTBR1(addr); if (ttbr_0_addr != null or ttbr_0_addr != null) { asm volatile ("tlbi vmalle1is"); // ensure completion of TLB invalidation asm volatile ("dsb ish"); asm volatile ("isb"); } } fn findTaskByPid(self: *Scheduler, pid: u16) !struct { index: u16, task_type: Task.TaskType } { for (self.scheduled_tasks, 0..) |*proc, i| { if (proc.pid == pid) return .{ .index = @as(u16, @truncate(i)), .task_type = .process }; } for (&self.env_actions, 0..) |*action, i| { if (action.pid == pid) return .{ .index = @as(u16, @truncate(i)), .task_type = .action }; } return Error.PidNotFound; } };
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/KSemaphore.zig
const std = @import("std"); const board = @import("board"); const Scheduler = @import("Scheduler.zig").Scheduler; const arm = @import("arm"); const CpuContext = arm.cpuContext.CpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; pub fn Semaphore(comptime max_process_waiting: ?usize) type { const max_process_waiting_queue = max_process_waiting orelse board.config.static_memory_reserves.ksemaphore_max_process_in_queue; return struct { const Self = @This(); const Error = error{ OutOfStaticMem, }; waiting_processes: [max_process_waiting_queue]?u16, i: isize, locked_tasks_index: u16, pub fn init(s: isize) Self { return .{ .waiting_processes = [_]?u16{0} ** max_process_waiting_queue, .locked_tasks_index = 0, .i = s, }; } pub fn wait(self: *Self, pid: u16, scheduler: *Scheduler, irq_context: *CpuContext) !void { self.i -= 1; if (self.i < max_process_waiting_queue) { scheduler.current_task.preempt_count += 1; self.locked_tasks_index += 1; if (self.locked_tasks_index > self.waiting_processes.len) return Error.OutOfStaticMem; self.waiting_processes[self.locked_tasks_index] = pid; try scheduler.setProcessState(pid, .halted, irq_context); } } pub fn signal(self: *Self, scheduler: *Scheduler) !void { if (self.i < max_process_waiting_queue) { if (self.waiting_processes[self.locked_tasks_index]) |locked_pid| { self.i += 1; self.locked_tasks_index -= 1; try scheduler.setProcessState(locked_pid, .running, null); scheduler.current_task.preempt_count -= 1; } } } }; }
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/UserPageAllocator.zig
const std = @import("std"); const arm = @import("arm"); const board = @import("board"); const utils = @import("utils"); const kprint = @import("periph").uart.UartWriter(.ttbr1).kprint; const mmu = arm.mmu; const granule = board.config.mem.va_user_space_gran; const userSpaceSizeInBytes = board.config.mem.user_space_size; const maxChunks: usize = @divExact(userSpaceSizeInBytes, granule.page_size); pub const UserPageAllocator = struct { const Error = error{ OutOfChunks, OutOfMem, PageAllocMinimum, PageAddrDoesNotAlign, AddrNotInMem, AddrNotValid, }; kernel_mem: std.bit_set.ArrayBitSet(usize, maxChunks), mem_start: usize, curr_page_pointer: usize, pub fn init() !UserPageAllocator { return UserPageAllocator{ .kernel_mem = std.bit_set.ArrayBitSet(usize, maxChunks).initEmpty(), // virt userspace 0x0 .mem_start = 0, .curr_page_pointer = 0, }; } pub fn allocNPage(self: *UserPageAllocator, n: usize) ![]u8 { // kprint("{d}, {d}, {d} \n", .{ maxChunks, self.curr_page_pointer + n, self.kernel_mem.capacity() }); if (n <= 0) return Error.PageAllocMinimum; if (self.curr_page_pointer + n > self.kernel_mem.capacity()) { kprint("SEARCHING \n", .{}); return try self.searchFreePages(n); } var ret_slice: []u8 = undefined; ret_slice.ptr = @alignCast(@as([*]u8, @ptrFromInt(self.mem_start + self.curr_page_pointer * granule.page_size))); ret_slice.len = granule.page_size * n; self.curr_page_pointer += n; // kprint("allocation addr: {*} \n", .{ret_slice.ptr}); return ret_slice; } fn searchFreePages(self: *UserPageAllocator, req_pages: usize) ![]u8 { var iterator = self.kernel_mem.iterator(.{ .kind = .set }); var i: usize = 0; var curr_set_bit_index: usize = 0; var last_set_bit_index: usize = 0; while (i <= self.kernel_mem.capacity()) : (i += 1) { curr_set_bit_index = iterator.next() orelse return Error.OutOfMem; if (curr_set_bit_index - last_set_bit_index >= req_pages) { var ret_slice: []u8 = undefined; ret_slice.ptr = @alignCast(@as([*]u8, @ptrFromInt(last_set_bit_index * granule.page_size))); ret_slice.len = granule.page_size * req_pages; return ret_slice; } last_set_bit_index = curr_set_bit_index; } return Error.OutOfMem; } pub fn freeNPage(self: *UserPageAllocator, page_addr: []u8, n: usize) !void { if ((try std.math.mod(usize, utils.toTtbr0(usize, @intFromPtr(page_addr.ptr)), granule.page_size)) != 0) return Error.PageAddrDoesNotAlign; const pointing_addr_start: usize = std.math.sub(usize, utils.toTtbr0(usize, @intFromPtr(page_addr.ptr)), self.mem_start) catch { return Error.AddrNotInMem; }; // safe bc page_address is multiple of page_size const n_page = pointing_addr_start / granule.page_size; self.kernel_mem.setRangeValue(.{ .start = n_page, .end = n_page + n + n }, false); self.curr_page_pointer -= n; } };
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/sharedKernelServices.zig
const board = @import("board"); pub const KernelAllocator = @import("KernelAllocator.zig").KernelAllocator; pub const UserPageAllocator = @import("UserPageAllocator.zig").UserPageAllocator; pub const Scheduler = @import("Scheduler.zig").Scheduler; pub const KSemaphore = @import("KSemaphore.zig").Semaphore; pub const SysCallsTopicsInterface = @import("SysCallsTopicsInterface.zig").SysCallsTopicsInterface; pub const StatusControl = @import("StatusControl.zig").StatusControl;
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/KernelAllocator.zig
const std = @import("std"); const alignForward = std.mem.alignForward; const board = @import("board"); const periph = @import("periph"); const utils = @import("utils"); const arm = @import("arm"); const kprint = periph.uart.UartWriter(.ttbr0).kprint; const addr = periph.rbAddr; const mmu = arm.mmu; const ProccessorRegMap = arm.processor.ProccessorRegMap; const kernelAllocatorChunkSize = 0x10000; pub const KernelAllocator = struct { const Error = error{ OutOfChunks, OutOfMem, AddrNotInMem, AddrNotValid, MemBaseNotAligned, }; const maxChunks = @divExact(board.config.mem.kernel_space_size - board.config.mem.k_stack_size, kernelAllocatorChunkSize); mem_base: usize, kernel_mem: [maxChunks]bool, used_chunks: usize, pub fn init(mem_base: usize) !KernelAllocator { if (mem_base % 8 != 0) return Error.MemBaseNotAligned; const ka = KernelAllocator{ .kernel_mem = [_]bool{false} ** maxChunks, // can currently only increase and indicates at which point findFree() is required .used_chunks = 0, .mem_base = mem_base, }; return ka; } pub fn alloc(self: *KernelAllocator, comptime T: type, n: usize, alignment: ?usize) ![]T { var alignm: usize = @alignOf(T); if (alignment) |a| alignm = a; const size = @sizeOf(T) * n; const req_chunks = try std.math.divCeil(usize, size, kernelAllocatorChunkSize); if (try self.findFree(self.used_chunks, size)) |free_mem_first_chunk| { for (self.kernel_mem[free_mem_first_chunk .. free_mem_first_chunk + req_chunks]) |*chunk| { chunk.* = true; } const alloc_addr = self.mem_base + (free_mem_first_chunk * kernelAllocatorChunkSize); const aligned_alloc_slice = @as([*]T, @ptrFromInt(utils.toTtbr1(usize, alignForward(usize, alloc_addr, alignm)))); return aligned_alloc_slice[0 .. n - 1]; } else if (self.used_chunks + req_chunks > maxChunks) { return Error.OutOfMem; } const first_chunk = self.used_chunks; const last_chunk = self.used_chunks + req_chunks; self.used_chunks += req_chunks; for (self.kernel_mem[first_chunk..last_chunk]) |*chunk| { chunk.* = true; } const alloc_addr = self.mem_base + (first_chunk * kernelAllocatorChunkSize); const aligned_alloc_slice = @as([*]T, @ptrFromInt(utils.toTtbr1(usize, alignForward(usize, alloc_addr, alignm)))); // kprint("allocation addr: {*} \n", .{aligned_alloc_slice[0 .. n - 1].ptr}); return aligned_alloc_slice[0 .. n - 1]; } /// finds continous free memory in fragmented kernel memory; marks returned memory as not free! pub fn findFree(self: *KernelAllocator, to_chunk: usize, req_size: usize) !?usize { var continous_chunks: usize = 0; const req_chunks = (try std.math.divCeil(usize, req_size, kernelAllocatorChunkSize)); for (self.kernel_mem, 0..) |chunk, i| { if (i >= to_chunk) { return null; } if (!chunk) { continous_chunks += 1; } else { continous_chunks = 0; } if (continous_chunks >= req_chunks) { var first_chunk = i; if (i > 0) first_chunk -= req_chunks; return first_chunk; } } return null; } pub fn free(self: *KernelAllocator, to_free: anytype) !void { const Slice = @typeInfo(@TypeOf(to_free)).Pointer; const byte_slice = std.mem.sliceAsBytes(to_free); const size = byte_slice.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; if (size == 0) return; const unsec_addr = utils.toTtbr0(usize, @intFromPtr(byte_slice.ptr)); // compensating for alignment const addr_unaligned = unsec_addr; if (addr_unaligned == utils.toTtbr0(usize, self.mem_base)) addr_unaligned -= (try std.math.mod(usize, unsec_addr, kernelAllocatorChunkSize)); if (addr_unaligned > (self.mem_base + (maxChunks * kernelAllocatorChunkSize))) return Error.AddrNotInMem; const i_chunk_to_free: usize = (try std.math.divCeil(usize, std.math.sub(usize, addr_unaligned, utils.toTtbr0(usize, self.mem_base)) catch { return Error.AddrNotInMem; }, kernelAllocatorChunkSize)) - 1; const n_chunks_to_free: usize = try std.math.divCeil(usize, size, kernelAllocatorChunkSize); for (&self.kernel_mem[i_chunk_to_free .. i_chunk_to_free + n_chunks_to_free]) |*chunk| { chunk.* = false; } } };
0
repos/MinimalRoboticsPlatform/src/kernel
repos/MinimalRoboticsPlatform/src/kernel/sharedKernelServices/StatusControl.zig
const std = @import("std"); const env = @import("environment"); const KernelAlloc = @import("KernelAllocator.zig").KernelAllocator; const StatusType = env.envConfTemplate.StatusType; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; pub const StatusControl = struct { const GenericStatus = struct { status_type: StatusType, name: []const u8, id: u16, mem_addr: usize, size: usize, }; const Error = error{ NameNotFound, TypesNotMatching, WrongInterface, }; // yes, thats the plural statuses: [env.env_config.countStatuses()]GenericStatus, mem_pool: []u8, pub fn init(kernel_alloc: *KernelAlloc) !StatusControl { var accumulatedBuffSize: usize = 0; var statuses = [_]GenericStatus{.{ .status_type = undefined, .name = undefined, .mem_addr = undefined, .size = undefined, .id = undefined }} ** env.env_config.countStatuses(); var i: usize = 0; for (&env.env_config.status_control) |*status_control_conf| { if (status_control_conf.status_type != .topic) { switch (status_control_conf.status_type) { .string => { accumulatedBuffSize += @sizeOf([100]u8); statuses[i] = GenericStatus{ .status_type = status_control_conf.status_type, .mem_addr = undefined, .size = @sizeOf([100]u8), .name = status_control_conf.name, .id = status_control_conf.id }; }, .usize, .isize => { accumulatedBuffSize += @sizeOf(usize); statuses[i] = GenericStatus{ .status_type = status_control_conf.status_type, .mem_addr = undefined, .size = @sizeOf(usize), .name = status_control_conf.name, .id = status_control_conf.id }; }, .bool => { accumulatedBuffSize += @sizeOf(bool); statuses[i] = GenericStatus{ .status_type = status_control_conf.status_type, .mem_addr = undefined, .size = @sizeOf(bool), .name = status_control_conf.name, .id = status_control_conf.id }; }, else => {}, } i += 1; } } const status_mem = try kernel_alloc.alloc(u8, accumulatedBuffSize, null); var used_status_mem: usize = 0; i = 0; for (&env.env_config.status_control) |*status_control_conf| { if (status_control_conf.status_type != .topic) { const size = status_control_conf.status_type.statusTypeLen() orelse return Error.WrongInterface; i += 1; statuses[i].mem_addr = @intFromPtr(status_mem[used_status_mem .. used_status_mem + size].ptr); used_status_mem += size; } } return .{ .statuses = statuses, .mem_pool = status_mem, }; } pub fn updateStatus(self: *StatusControl, name: []const u8, value: anytype) !void { if (self.findStatusByName(name)) |index| { if (!self.statuses[index].status_type.isTypeEqual(@TypeOf(value))) return Error.TypesNotMatching; var value_as_bytes: []const u8 = undefined; value_as_bytes.ptr = @as([*]const u8, @ptrCast(&value)); value_as_bytes.len = @sizeOf(@TypeOf(value)); std.mem.copy(u8, @as([]u8, @ptrFromInt(self.statuses[index].mem_addr)), value_as_bytes); } } pub fn updateStatusRaw(self: *StatusControl, id: u16, val_mem_addr: usize) !void { if (self.findStatusById(id)) |index| { var copy_src: []u8 = undefined; copy_src.ptr = @ptrFromInt(self.statuses[index].mem_addr); copy_src.len = self.statuses[index].size; @memcpy(copy_src, @as([*]u8, @ptrFromInt(val_mem_addr))); } else return Error.NameNotFound; } pub fn readStatus(self: *StatusControl, comptime InpT: type, comptime name: []const u8) !InpT { const T: type = (try env.env_config.getStatusInfo(name)).type; if (self.findStatusByName(name)) |index| { return @as(*T, @ptrFromInt(self.statuses[index].mem_addr)).*; } return Error.NameNotFound; } pub fn readStatusRaw(self: *StatusControl, id: u16, ret_buff: usize) !void { if (self.findStatusById(id)) |index| { var copy_src: []u8 = undefined; copy_src.ptr = @ptrFromInt(ret_buff); copy_src.len = self.statuses[index].size; @memcpy(copy_src, @as([*]u8, @ptrFromInt(self.statuses[index].mem_addr))); } else return Error.NameNotFound; } // returns index fn findStatusByName(self: *StatusControl, name: []const u8) ?usize { for (&self.statuses, 0..) |*status, i| { if (std.mem.eql(u8, status.name, name)) return i; } return null; } // returns index fn findStatusById(self: *StatusControl, id: u16) ?usize { for (&self.statuses, 0..) |*status, i| { if (status.id == id) return i; } return null; } };
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/configTemplates/boardBuildConfigTemplate.zig
pub const BoardBuildConf = struct { boardName: []const u8, has_rom: bool, // the kernel is loaded by into 0x8000 ram by the gpu, so no relocation (or rom) required rom_start_addr: ?usize, bl_load_addr: ?usize, va_start: usize, qemu_launch_command: []const []const u8, };
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/configTemplates/envConfigTemplate.zig
pub const TopicTypePlaceHolder = struct {}; pub const StatusType = enum { string, usize, isize, bool, topic, pub fn statusTypeToNativeType(comptime self: StatusType) ?type { switch (self) { inline .usize => return usize, inline .isize => return isize, inline .bool => return bool, inline .string => return []const u8, inline .topic => return null, } } pub fn isTypeEqual(self: StatusType, comptime inp_type: type) bool { switch (self) { inline .usize => if (inp_type == usize) return true, inline .isize => if (inp_type == isize) return true, inline .bool => if (inp_type == bool) return true, inline .string => if (inp_type == [100]u8) return true, inline .topic => return false, } return false; } pub fn statusTypeLen(self: StatusType) ?usize { switch (self) { .usize => return @sizeOf(usize), .isize => return @sizeOf(isize), .bool => return @sizeOf(bool), .string => return @sizeOf([]const u8), .topic => return null, } } }; pub const TopicBufferTypes = enum { RingBuffer, ContinousBuffer, }; pub const TopicConf = struct { buffer_type: TopicBufferTypes, buffer_size: usize, // permission_level: }; pub const StatusControlConf = struct { status_type: StatusType, name: []const u8, id: u16, topic_conf: ?TopicConf, }; pub fn EnvConfig(comptime n_statuses: usize) type { return struct { const Self = @This(); const Error = error{ StatusNameNotFound, StatusTypeNotMatching, WrongStatusInterface }; // comms model.. status_control: [n_statuses]StatusControlConf, pub fn getStatusInfo(comptime self: *const Self, comptime name: []const u8) Error!struct { id: u16, type: ?type } { statuses: inline for (self.status_control) |status_control_conf| { comptime var found: bool = true; if (status_control_conf.name.len != name.len) { found = false; continue :statuses; } inline for (status_control_conf.name, 0..) |char, j| { if (char != name[j]) { found = false; continue :statuses; } } if (found) return .{ .id = status_control_conf.id, .type = status_control_conf.status_type.statusTypeToNativeType() }; } return Error.StatusNameNotFound; } pub fn countTopics(self: *const Self) usize { var n_topics: usize = 0; for (&self.status_control) |*status_control_conf| { if (status_control_conf.*.status_type == .topic) n_topics += 1; } return n_topics; } pub fn countStatuses(self: *const Self) usize { var n_topics: usize = 0; for (&self.status_control) |*status_control_conf| { if (status_control_conf.*.status_type != .topic) n_topics += 1; } return n_topics; } }; }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/configTemplates/boardConfigTemplate.zig
const std = @import("std"); pub const AddrSpace = enum(u8) { ttbr1 = 1, ttbr0 = 0, pub fn isKernelSpace(self: AddrSpace) bool { return @intFromEnum(self) != 0; } }; pub const Granule = struct { pub const GranuleParams = struct { page_size: usize, // not really neccessary but required to keep section size down table_size: usize, lvls_required: TransLvl, }; // correct term for .page_size is .block_size pub const FourkSection: GranuleParams = .{ .page_size = 2097152, .table_size = 512, .lvls_required = .second_lvl }; pub const Fourk: GranuleParams = .{ .page_size = 4096, .table_size = 512, .lvls_required = .third_lvl }; pub const Sixteenk: GranuleParams = .{ .page_size = 16384, .table_size = 2048, .lvls_required = .third_lvl }; pub const Sixtyfourk: GranuleParams = .{ .page_size = 65536, .table_size = 8192, .lvls_required = .second_lvl }; }; pub const TransLvl = enum(usize) { first_lvl = 0, second_lvl = 1, third_lvl = 2 }; pub const BoardConfig = struct { pub const BoardMemLayout = struct { va_start: usize, bl_stack_size: usize, k_stack_size: usize, app_stack_size: usize, app_vm_mem_size: usize, bl_load_addr: ?usize, rom_size: ?usize, ram_start_addr: usize, ram_size: usize, kernel_space_size: usize, user_space_size: usize, va_kernel_space_gran: Granule.GranuleParams, va_kernel_space_page_table_capacity: usize, va_user_space_gran: Granule.GranuleParams, va_user_space_page_table_capacity: usize, storage_start_addr: usize, storage_size: usize, }; pub const StaticMemoryReserves = struct { // *_max_process_in_queue describes the array which contains the list of tasks currently waiting. // The array can be portioned quite big since it's only the pids being stored ksemaphore_max_process_in_queue: usize, // [n]usize semaphore_max_process_in_queue: usize, // [n]usize mutex_max_process_in_queue: usize, // [n]Semaphore ! topics_max_process_in_queue: usize, }; board_name: []const u8, mem: BoardMemLayout, static_memory_reserves: StaticMemoryReserves, scheduler_freq_in_hertz: usize, pub fn checkConfig(self: BoardConfig) void { if (!self.mem.has_rom and self.mem.rom_start_addr == null and self.mem.bl_load_addr == null) @panic("if there is no rom, a boot loader start (or entry) address is required! \n"); if (!self.mem.has_rom and self.mem.rom_start_addr != null and self.mem.bl_load_addr != null) @panic("if there is rom, no boot loader start (or entry) address is supported at the moment! \n"); // if (self.mem.kernel_space_size + self.mem.user_space_size > self.mem.ram_size) // @panic("since no swapping is supported, user/kernel space cannot exceed ram size \n"); // optional does does not support equal operator.. if ((!self.mem.has_rom and self.mem.rom_size == null and self.mem.rom_start_addr != null) or (self.mem.rom_size != null and self.mem.rom_start_addr == null)) @panic("if rom is disabled, both rom addr and len have to be null \n"); } }; pub fn Driver(comptime TimerType: type, comptime SecondaryInterruptControllerType: ?type) type { return struct { timerDriver: TimerType, secondaryInterruptConrtollerDriver: ?(SecondaryInterruptControllerType orelse type), }; }
0
repos/MinimalRoboticsPlatform/src
repos/MinimalRoboticsPlatform/src/configTemplates/configTemplates.zig
pub const boardConfigTemplate = @import("boardConfigTemplate.zig"); pub const envConfigTemplate = @import("envConfigTemplate.zig");
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; pub const env_config = envConfTemplate.EnvConfig(2){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 1, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { var irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/app1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app1 initial pid: {d} \n", .{pid}); while (true) { test_counter += 1; kprint("app{d} test print {d} \n", .{ pid, test_counter }); kprint("sleeping... \n", .{}); sysCalls.sleep(std.time.ns_per_s) catch |e| { kprint("syscall err {s} \n", .{@errorName(e)}); }; // if (test_counter == 40000) { // test_counter += 1; // // sysCalls.killTask(1); // sysCalls.killTaskRecursively(1); // } } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/app1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/app2/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; var shared_thread_counter: isize = 0; var mutex = Mutex.init(); var shared_mutex: *Mutex = &mutex; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app2 initial pid: {d} \n", .{pid}); while (true) { test_counter += 1; kprint("app{d} test print {d} \n", .{ pid, test_counter }); } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/userApps/app2/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .got : { *(.got.plt); *(.got); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; pub const testThread = @import("testThread.zig"); // threads array is loaded and inited by the kernel pub const threads = [_]Thread{testThread.threadFn};
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess
repos/MinimalRoboticsPlatform/src/environments/basicMultiProcess/kernelThreads/testThread.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn threadFn(scheduler: *Scheduler) noreturn { var i: usize = 0; while (true) { i += 1; kprint("kernel test thread {d} \n", .{i}); } scheduler.exitTask() catch |e| { kprint("[error] exitTask error: {s} \n", .{@errorName(e)}); while (true) {} }; }
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; pub const env_config = envConfTemplate.EnvConfig(2){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 1, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { var irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/app2/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("initial pid: {d} \n", .{pid}); var app_alloc = AppAlloc.init(null) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem, testThread, .{@as(u16, @truncate(pid))}) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem_2 = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem_2, testThread2, .{@as(u16, @truncate(pid))}) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; while (true) { kprint("multithreading test counter \n", .{}); } } pub fn testThread(parent_pid: u16) void { const pid: usize = sysCalls.getPid() catch { return; }; while (true) { kprint("TEST THREAD 1 (daddy proc.: {d}, my pid: {d})\n", .{ parent_pid, pid }); } } pub fn testThread2(parent_pid: u16) void { const pid: usize = sysCalls.getPid() catch { return; }; while (true) { kprint("TEST THREAD 2 (daddy proc.: {d}, my pid: {d}) \n", .{ parent_pid, pid }); } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/userApps/app2/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .got : { *(.got.plt); *(.got); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading
repos/MinimalRoboticsPlatform/src/environments/basicMultiThreading/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; // threads array is loaded and inited by the kernel pub const threads = [_]Thread{};
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; pub const env_config = envConfTemplate.EnvConfig(2){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 1, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { var irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/app1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { while (true) { test_counter += 1; kprint("app{d} test print {d} \n", .{ pid, test_counter }); // if (test_counter == 40000) { // test_counter += 1; // // sysCalls.killTask(1); // sysCalls.killTaskRecursively(1); // } } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/app1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/app2/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; var shared_thread_counter: isize = 0; var mutex = Mutex.init(); var shared_mutex: *Mutex = &mutex; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("initial pid: {d} \n", .{pid}); var app_alloc = AppAlloc.init(null) catch |e| { kprint("[panic] AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem, testThread, .{@as(u16, @truncate(pid))}) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem_2 = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem_2, testThread2, .{@as(u16, @truncate(pid))}) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; while (true) { test_counter += 1; kprint("app{d} test print {d} \n", .{ pid, test_counter }); // if (test_counter == 10000) { // test_counter += 1; // sysCalls.createThread(&alloc, &testThread) catch |e| { // kprint("[panic] AppAlloc init error: {s}\n", .{@errorName(e)}); // while (true) {} // }; // } } } pub fn testThread(parent_pid: u16) void { const pid: usize = sysCalls.getPid() catch { return; }; while (true) { kprint("TEST THREAD 1 (daddy proc.: {d}, my pid: {d})\n", .{ parent_pid, pid }); // shared_mutex.lock(); shared_thread_counter += 1; // shared_mutex.unlock(); } } pub fn testThread2(parent_pid: u16) void { const pid: usize = sysCalls.getPid() catch { return; }; while (true) { kprint("TEST THREAD 2 (daddy proc.: {d}, my pid: {d}) \n", .{ parent_pid, pid }); // shared_mutex.lock(); shared_thread_counter -= 1; // shared_mutex.unlock(); } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/userApps/app2/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .got : { *(.got.plt); *(.got); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading
repos/MinimalRoboticsPlatform/src/environments/multiProcAndThreading/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; // threads array is loaded and inited by the kernel pub const threads = [_]Thread{};
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/actionTest/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; const Action = envConfTemplate.Action; pub const env_config = envConfTemplate.EnvConfig(3){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .bool, .name = "groundContact", .id = 1, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 2, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/actionTest
repos/MinimalRoboticsPlatform/src/environments/actionTest/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { const irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; const irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; const irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest
repos/MinimalRoboticsPlatform/src/environments/actionTest/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/actionTest
repos/MinimalRoboticsPlatform/src/environments/actionTest/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/app1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app1 initial pid: {d} \n", .{pid}); var read_state: bool = true; sysCalls.updateStatus("groundContact", true) catch |e| { kprint("sysCalls updateStatus err: {s} \n", .{@errorName(e)}); }; while (true) { read_state = sysCalls.readStatus(bool, "groundContact") catch |e| { kprint("sysCalls readStatus err: {s} \n", .{@errorName(e)}); while (true) {} }; kprint("status read 1: {any} \n", .{read_state}); if (read_state) { sysCalls.updateStatus("groundContact", false) catch |e| { kprint("sysCalls updateStatus err: {s} \n", .{@errorName(e)}); }; kprint("status set 1 to false \n", .{}); } } } // var test_counter: usize = 0; // export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { // kprint("app1 initial pid: {d} \n", .{pid}); // while (true) { // test_counter += 1; // sysCalls.updateStatus("height", @intCast(isize, test_counter)) catch |e| { // kprint("sysCalls updateStatus err: {s} \n", .{@errorName(e)}); // }; // var read = sysCalls.readStatus(isize, "height") catch |e| { // kprint("sysCalls readStatus err: {s} \n", .{@errorName(e)}); // while (true) {} // }; // kprint("status read: {d} \n", .{read}); // } // }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/app1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/app2/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; var shared_thread_counter: isize = 0; var mutex = Mutex.init(); var shared_mutex: *Mutex = &mutex; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app2 initial pid: {d} \n", .{pid}); var read_state: bool = false; while (true) { // test_counter += 1; // kprint("app{d} test print {d} \n", .{ pid, test_counter }); read_state = sysCalls.readStatus(bool, "groundContact") catch |e| { kprint("sysCalls readStatus err: {s} \n", .{@errorName(e)}); while (true) {} }; kprint("status read 2: {any} \n", .{read_state}); if (!read_state) { sysCalls.updateStatus("groundContact", true) catch |e| { kprint("sysCalls updateStatus err: {s} \n", .{@errorName(e)}); }; kprint("status set 2 to true \n", .{}); } } }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps
repos/MinimalRoboticsPlatform/src/environments/actionTest/userApps/app2/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .got : { *(.got.plt); *(.got); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/actionTest
repos/MinimalRoboticsPlatform/src/environments/actionTest/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; pub const testThread = @import("testThread.zig"); // threads array is loaded and inited by the kernel pub const threads = [_]Thread{testThread.threadFn};
0
repos/MinimalRoboticsPlatform/src/environments/actionTest
repos/MinimalRoboticsPlatform/src/environments/actionTest/kernelThreads/testThread.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn threadFn(scheduler: *Scheduler) noreturn { _ = scheduler; while (true) { // kprint("broken \n", .{}); } }
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; pub const env_config = envConfTemplate.EnvConfig(3){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 1, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.ContinousBuffer, .buffer_size = 1024, }, }, .{ .status_type = .topic, .name = "radar-sensor", .id = 2, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { var irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; var irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/app1/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const SharedMemTopicsInterface = appLib.SharedMemTopicsInterface; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; var shared_thread_counter: isize = 0; var mutex = Mutex.init(); var shared_mutex: *Mutex = &mutex; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app1 initial pid: {d} \n", .{pid}); var ret: usize = 0; var ret_buff: []u8 = undefined; ret_buff.ptr = @as([*]u8, @ptrCast(&ret)); ret_buff.len = @sizeOf(@TypeOf(ret)); var topics_interf = SharedMemTopicsInterface.init() catch |e| { kprint("app1 SharedMemTopicsInterface init err: {s} \n", .{@errorName(e)}); while (true) {} }; // var topics_interfaces_read = @intToPtr(*volatile [1000]usize, 0x20000000); while (true) { // kprint("topics interface read: {any} \n", .{topics_interfaces_read.*}); const read_len: usize = topics_interf.read("height-sensor", ret_buff) catch |e| { kprint("app1 read err: {s} \n", .{@errorName(e)}); while (true) {} }; if (read_len < ret_buff.len) kprint("buffer partially filled {d}/ {d} bytes \n", .{ read_len, ret_buff.len }); kprint("read: {any} \n", .{ret}); } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/app1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/app2/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const SharedMemTopicsInterface = appLib.SharedMemTopicsInterface; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; const utils = appLib.utils; var test_counter: usize = 0; var shared_thread_counter: isize = 0; var mutex = Mutex.init(); var shared_mutex: *Mutex = &mutex; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("app2 initial pid: {d} \n", .{pid}); var topics_interf = SharedMemTopicsInterface.init() catch |e| { kprint("app2 SharedMemTopicsInterface init err: {s} \n", .{@errorName(e)}); while (true) {} }; var counter: usize = 0; var payload: []u8 = undefined; payload.ptr = @as([*]u8, @ptrCast(&counter)); payload.len = @sizeOf(@TypeOf(counter)); while (true) { counter += 1; const written_data = topics_interf.write("height-sensor", payload) catch |e| { kprint("app2 write err: {s} \n", .{@errorName(e)}); while (true) {} }; if (written_data < payload.len) kprint("buffer partially filled {d}/ {d} bytes \n", .{ written_data, payload.len }); kprint("pushed: {d} \n", .{counter}); } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/userApps/app2/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) *(.text.); *(.text.*); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .got : { *(.got.plt); *(.got); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest
repos/MinimalRoboticsPlatform/src/environments/sharedMemTopicsTest/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; // threads array is loaded and inited by the kernel pub const threads = [_]Thread{};
0
repos/MinimalRoboticsPlatform/src/environments
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/envConfig.zig
pub const envConfTemplate = @import("configTemplates").envConfigTemplate; const StatusControlConf = envConfTemplate.StatusControlConf; pub const env_config = envConfTemplate.EnvConfig(2){ .status_control = [_]StatusControlConf{ .{ .status_type = .isize, .name = "height", .id = 0, .topic_conf = null, }, .{ .status_type = .topic, .name = "height-sensor", .id = 1, .topic_conf = .{ .buffer_type = envConfTemplate.TopicBufferTypes.RingBuffer, .buffer_size = 1024, }, }, }, };
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/setupRoutines/raspi3bSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const ProccessorRegMap = arm.processor.ProccessorRegMap; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn bcm2835Setup(scheduler: *Scheduler) void { _ = scheduler; // enabling arm generic timer irq @as(*volatile u32, @ptrFromInt(board.PeriphConfig(.ttbr1).ArmGenericTimer.base_address)).* = 1 << 1 | 1 << 3; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); if (board.driver.secondaryInterruptConrtollerDriver) |secondary_ic| { secondary_ic.addIcHandler(&irqHandler) catch |e| { kprint("[error] addIcHandler error: {s} \n", .{@errorName(e)}); while (true) {} }; } kprint("inited raspberry secondary Ic and arm timer \n", .{}); } pub const RegValues = struct { // all banks are lister here: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/brcm%2Cbcm2835-armctrl-ic.txt pub const Bank0 = enum(u32) { armTimer = 1 << 0, armMailbox = 1 << 1, armDoorbell0 = 1 << 2, armDoorbell1 = 1 << 3, vpu0Halted = 1 << 4, vpu1Halted = 1 << 5, illegalType0 = 1 << 6, illegalType1 = 1 << 7, pending1 = 1 << 8, pending2 = 1 << 9, notDefined = 0, }; pub const Bank1 = enum(u32) { timer0 = 1 << 0, timer1 = 1 << 1, timer2 = 1 << 2, timer3 = 1 << 3, codec0 = 1 << 4, codec1 = 1 << 5, codec2 = 1 << 6, vcJpeg = 1 << 7, isp = 1 << 8, vcUsb = 1 << 9, vc3d = 1 << 10, transposer = 1 << 11, multicoresync0 = 1 << 12, multicoresync1 = 1 << 13, multicoresync2 = 1 << 14, multicoresync3 = 1 << 15, dma0 = 1 << 16, dma1 = 1 << 17, vcDma2 = 1 << 18, vcDma3 = 1 << 19, dma4 = 1 << 20, dma5 = 1 << 21, dma6 = 1 << 22, dma7 = 1 << 23, dma8 = 1 << 24, dma9 = 1 << 25, dma10 = 1 << 26, // 27: dma11-14 - shared interrupt for dma 11 to 14 dma11 = 1 << 27, // 28: dmaall - triggers on all dma interrupts (including chanel 15) dmaall = 1 << 28, aux = 1 << 29, arm = 1 << 30, vpudma = 1 << 31, notDefined = 0, }; // bank2 pub const Bank2 = enum(u32) { hostport = 1 << 0, videoscaler = 1 << 1, ccp2tx = 1 << 2, sdc = 1 << 3, dsi0 = 1 << 4, ave = 1 << 5, cam0 = 1 << 6, cam1 = 1 << 7, hdmi0 = 1 << 8, hdmi1 = 1 << 9, pixelValve1 = 1 << 10, i2cSpislv = 1 << 11, dsi1 = 1 << 12, pwa0 = 1 << 13, pwa1 = 1 << 14, cpr = 1 << 15, smi = 1 << 16, gpio0 = 1 << 17, gpio1 = 1 << 18, gpio2 = 1 << 19, gpio3 = 1 << 20, vci2c = 1 << 21, vcSpi = 1 << 22, vcI2spcm = 1 << 23, vcSdio = 1 << 24, vcUart = 1 << 25, slimbus = 1 << 26, vec = 1 << 27, cpg = 1 << 28, rng = 1 << 29, vcArasansdio = 1 << 30, avspmon = 1 << 31, notDefined = 0, }; }; // bcm2835 interrupt controller handler for raspberry const Bank0 = RegValues.Bank0; const Bank1 = RegValues.Bank1; const Bank2 = RegValues.Bank2; pub fn irqHandler(context: *cpuContext.CpuContext) void { const irq_bank_0 = std.meta.intToEnum(Bank0, board.SecondaryInterruptControllerKpiType.RegMap.pendingBasic.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; const irq_bank_1 = std.meta.intToEnum(Bank1, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq1.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; const irq_bank_2 = std.meta.intToEnum(Bank2, board.SecondaryInterruptControllerKpiType.RegMap.pendingIrq2.*) catch |e| { kprint("[panic] std meta intToEnum error: {s} \n", .{@errorName(e)}); while (true) {} }; switch (irq_bank_0) { // One or more bits set in pending register 1 Bank0.pending1 => { switch (irq_bank_1) { Bank1.timer1 => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "bcm2835_timer")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported 1 irq num: {s} \n", .{@tagName(irq_bank_1)}); }, } }, // One or more bits set in pending register 2 Bank0.pending2 => { switch (irq_bank_2) { else => { // kprint("Not supported bank 2 irq num: {s} \n", .{@tagName(irq_bank_0)}); }, } }, Bank0.armTimer => { if (std.mem.eql(u8, board.driver.timerDriver.timer_name, "arm_gt")) { board.driver.timerDriver.timerTick(context) catch |e| { kprint("[panic] timerDriver timerTick error: {s} \n", .{@errorName(e)}); while (true) {} }; } }, else => { // kprint("Not supported bank(neither 1/2) irq num: {d} \n", .{intController.RegMap.pendingBasic.*}); // raspberries timers are a mess and I'm currently unsure if the Arm Generic timer // has an enum defined in the banks or if it's not defined through the bcm28835 system. }, } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/setupRoutines/routines.zig
const board = @import("board"); const std = @import("std"); const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const raspi3bSetup = @import("raspi3bSetup.zig").bcm2835Setup; const qemuVirtSetup = @import("qemuVirtSetup.zig").qemuVirtSetup; const SetupRoutine = fn (scheduler: *Scheduler) void; const boardSpecificSetup = blk: { if (std.mem.eql(u8, board.config.board_name, "raspi3b")) { break :blk [_]SetupRoutine{raspi3bSetup}; } else if (std.mem.eql(u8, board.config.board_name, "qemuVirt")) { break :blk [_]SetupRoutine{qemuVirtSetup}; } }; // setupRoutines array is loaded and inited by the kernel pub const setupRoutines = [_]SetupRoutine{} ++ boardSpecificSetup;
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/setupRoutines/qemuVirtSetup.zig
const std = @import("std"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const ProccessorRegMap = arm.processor.ProccessorRegMap; const gic = arm.gicv2.Gic(.ttbr1); const InterruptIds = gic.InterruptIds; const periph = @import("periph"); const kprint = periph.uart.UartWriter(.ttbr1).kprint; const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; pub fn qemuVirtSetup(scheduler: *Scheduler) void { _ = scheduler; gic.init() catch |e| { kprint("[panic] gic init error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdConfig(InterruptIds.non_secure_physical_timer, 0x2) catch |e| { kprint("[panic] gicd gicdConfig error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetPriority(InterruptIds.non_secure_physical_timer, 0) catch |e| { kprint("[panic] gicd setPriority error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdSetTarget(InterruptIds.non_secure_physical_timer, 1) catch |e| { kprint("[panic] gicd setTarget error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdClearPending(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicd clearPending error: {s}\n", .{@errorName(e)}); while (true) {} }; gic.Gicd.gicdEnableInt(InterruptIds.non_secure_physical_timer) catch |e| { kprint("[panic] gicdEnableInt address calc error: {s}\n", .{@errorName(e)}); while (true) {} }; ProccessorRegMap.DaifReg.setDaifClr(.{ .debug = true, .serr = true, .irqs = true, .fiqs = true, }); }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/semaphoreTest/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const Semaphore = appLib.Semaphore(null); const kprint = appLib.sysCalls.SysCallPrint.kprint; var shared_resource: isize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; var app_alloc = AppAlloc.init(null) catch |e| { kprint("[panic] AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; var test_sem = Semaphore.init(1); // eventual-todo => remove allcoations const thread_stack_mem = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem, testThread1, .{&test_sem}) catch |e| { kprint("sysCalls createThread error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem_2 = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem_2, testThread2, .{&test_sem}) catch |e| { kprint("sysCalls createThread error: {s}\n", .{@errorName(e)}); while (true) {} }; while (true) {} } fn testThread1(test_sem: *Semaphore) void { while (true) { kprint("thread1 waiting \n", .{}); test_sem.wait(null) catch |e| { kprint("semaphore wait error: {s}\n", .{@errorName(e)}); while (true) {} }; kprint("i: {d} \n", .{test_sem.i}); shared_resource += 1; kprint("thread1 signaling {d} \n", .{test_sem.i}); test_sem.signal() catch |e| { kprint("semaphore signal error: {s}\n", .{@errorName(e)}); while (true) {} }; kprint("i: {d} \n", .{test_sem.i}); // kprint("thread1 last {d} \n", .{test_sem.i}); } } fn testThread2(test_sem: *Semaphore) void { while (true) { kprint("thread2 waiting {d} \n", .{test_sem.i}); test_sem.wait(null) catch |e| { kprint("semaphore wait error: {s}\n", .{@errorName(e)}); while (true) {} }; kprint("i: {d} \n", .{test_sem.i}); shared_resource -= 1; kprint("thread2 signaling {d} \n", .{test_sem.i}); test_sem.signal() catch |e| { kprint("semaphore signal error: {s}\n", .{@errorName(e)}); while (true) {} }; kprint("i: {d} \n", .{test_sem.i}); // kprint("thread2 last i: {d} \n", .{test_sem.i}); } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/semaphoreTest/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/actions/action1/main.zig
const std = @import("std"); const appLib = @import("appLib"); const board = @import("board"); const arm = @import("arm"); const cpuContext = arm.cpuContext; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const kprint = appLib.sysCalls.SysCallPrint.kprint; var test_counter: usize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { _ = pid; while (true) {} }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/actions
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/actions/action1/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/_mutexTest/main.zig
const std = @import("std"); const board = @import("board"); const appLib = @import("appLib"); const Mutex = appLib.Mutex; const AppAlloc = appLib.AppAllocator; const sysCalls = appLib.sysCalls; const utils = appLib.utils; const kprint = appLib.sysCalls.SysCallPrint.kprint; var shared_thread_counter: isize = 0; export fn app_main(pid: usize) linksection(".text.main") callconv(.C) noreturn { kprint("initial pid: {d} \n", .{pid}); var app_alloc = AppAlloc.init(null) catch |e| { kprint("AppAlloc init error: {s}\n", .{@errorName(e)}); while (true) {} }; var mutex = Mutex.init(); const thread_stack_mem = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem, testThread2, .{&mutex}) catch |e| { kprint("createThread init error: {s}\n", .{@errorName(e)}); while (true) {} }; const thread_stack_mem_2 = app_alloc.alloc(u8, board.config.mem.app_stack_size, 16) catch |e| { kprint("AppAlloc alloc error: {s}\n", .{@errorName(e)}); while (true) {} }; sysCalls.createThread(thread_stack_mem_2, testThread, .{&mutex}) catch |e| { kprint("createThread init error: {s}\n", .{@errorName(e)}); while (true) {} }; while (true) {} } pub fn testThread2(mutex: *Mutex) void { while (true) { kprint("thread2 locking.. \n", .{}); mutex.lock() catch |e| { kprint("mutex lock error: {s}\n", .{@errorName(e)}); while (true) {} }; shared_thread_counter -= 1; kprint("thread2 accessing shared mutex protected shared resource {d} \n", .{shared_thread_counter}); mutex.unlock(); kprint("thread2 unlocked.. \n", .{}); } } pub fn testThread(mutex: *Mutex) void { while (true) { kprint("thread1 locking.. \n", .{}); mutex.lock() catch |e| { kprint("mutex lock error: {s}\n", .{@errorName(e)}); while (true) {} }; shared_thread_counter += 1; kprint("thread1 accessing shared mutex protected shared resource {d} \n", .{shared_thread_counter}); mutex.unlock(); kprint("thread1 unlocked.. \n", .{}); } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/userApps/_mutexTest/linker.ld
ENTRY(app_main) SECTIONS { . = 0x0; .text : ALIGN(16) { *(.text.main) } .got : { *(.got.plt); *(.got); } .rodata : ALIGN(0x8) { *(.rodata); *(.rodata.*); } .bss : ALIGN(0x10) { _bss_start = .; *(.bss.*); *(COMMON); _bss_end = .; } .data : { *(.data); *(.data.*); } .heap (NOLOAD) : ALIGN(8) { _heap_start = .; } }
0
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest
repos/MinimalRoboticsPlatform/src/environments/basicKernelFunctionalityTest/kernelThreads/threads.zig
const sharedKernelServices = @import("sharedKernelServices"); const Scheduler = sharedKernelServices.Scheduler; const Thread = fn (scheduler: *Scheduler) noreturn; // threads array is loaded and inited by the kernel pub const threads = [_]Thread{};