Merge branch 'remove_physmap' into 'master'

Remove physmap

See merge request redox-os/drivers!102
This commit is contained in:
Jeremy Soller
2023-07-19 11:29:52 +00:00
67 changed files with 623 additions and 361 deletions
Generated
+133 -243
View File
@@ -7,6 +7,7 @@ name = "ac97d"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"log",
"redox-daemon",
"redox-log",
@@ -21,6 +22,7 @@ version = "0.1.0"
dependencies = [
"aml",
"amlserde",
"common",
"log",
"num-derive",
"num-traits",
@@ -41,6 +43,7 @@ dependencies = [
"bitflags 1.2.1",
"block-io-wrapper",
"byteorder 1.4.3",
"common",
"log",
"partitionlib",
"redox-daemon",
@@ -53,6 +56,7 @@ name = "alxd"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"netutils",
"redox-daemon",
"redox_event",
@@ -78,9 +82,15 @@ dependencies = [
"aml",
"rustc-hash",
"serde",
"toml 0.7.3",
"toml 0.7.6",
]
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -101,9 +111,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.71"
version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
[[package]]
name = "arg_parser"
@@ -189,9 +199,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "bitflags"
version = "2.3.2"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbe3c979c178231552ecba20214a8272df4e09f232a87aef4320cf06539aded"
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
[[package]]
name = "bitvec"
@@ -217,9 +227,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7"
[[package]]
name = "bumpalo"
version = "3.12.0"
version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "byteorder"
@@ -263,13 +273,13 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.24"
version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-integer",
"num-traits",
"time",
"wasm-bindgen",
@@ -301,22 +311,10 @@ dependencies = [
]
[[package]]
name = "cmake"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130"
name = "common"
version = "0.1.0"
dependencies = [
"cc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width",
"redox_syscall 0.3.5",
]
[[package]]
@@ -346,12 +344,12 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.7"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c"
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.15",
"crossbeam-utils 0.8.16",
]
[[package]]
@@ -361,7 +359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.15",
"crossbeam-utils 0.8.16",
]
[[package]]
@@ -377,74 +375,31 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.15"
version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "cxx"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2",
"quote",
"scratch",
"syn 2.0.13",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
[[package]]
name = "cxxbridge-macro"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.13",
]
[[package]]
name = "e1000d"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"netutils",
"redox-daemon",
"redox_event",
"redox_syscall 0.3.5",
]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "extra"
version = "0.1.0"
@@ -534,7 +489,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.13",
"syn 2.0.26",
]
[[package]]
@@ -580,9 +535,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.3"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]]
name = "heck"
@@ -604,9 +559,9 @@ dependencies = [
[[package]]
name = "iana-time-zone"
version = "0.1.56"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613"
dependencies = [
"android_system_properties",
"core-foundation-sys",
@@ -618,12 +573,11 @@ dependencies = [
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cxx",
"cxx-build",
"cc",
]
[[package]]
@@ -631,6 +585,7 @@ name = "ided"
version = "0.1.0"
dependencies = [
"block-io-wrapper",
"common",
"log",
"partitionlib",
"pcid",
@@ -655,6 +610,7 @@ name = "ihdad"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"log",
"pcid",
"redox-daemon",
@@ -666,11 +622,11 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.9.3"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [
"autocfg 1.1.0",
"equivalent",
"hashbrown",
]
@@ -706,15 +662,16 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.6"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "ixgbed"
version = "1.0.0"
dependencies = [
"bitflags 1.2.1",
"common",
"netutils",
"redox-daemon",
"redox_event",
@@ -723,9 +680,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.61"
version = "0.3.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
dependencies = [
"wasm-bindgen",
]
@@ -758,15 +715,6 @@ version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "link-cplusplus"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
dependencies = [
"cc",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@@ -775,9 +723,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "lock_api"
version = "0.4.9"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
dependencies = [
"autocfg 1.1.0",
"scopeguard",
@@ -893,16 +841,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg 1.1.0",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
@@ -925,6 +863,7 @@ dependencies = [
"arrayvec 0.5.2",
"bitflags 1.2.1",
"block-io-wrapper",
"common",
"crossbeam-channel 0.4.4",
"futures",
"log",
@@ -933,28 +872,24 @@ dependencies = [
"redox-daemon",
"redox-log",
"redox_syscall 0.3.5",
"smallvec 1.10.0",
"smallvec 1.11.0",
]
[[package]]
name = "once_cell"
version = "1.17.1"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "orbclient"
version = "0.3.44"
source = "git+https://gitlab.redox-os.org/redox-os/orbclient.git#21d152240c4fc290a97d3d7a5adbc35ea495fdf9"
version = "0.3.45"
source = "git+https://gitlab.redox-os.org/redox-os/orbclient.git#def603f25763db3b8222b9cc84983cef5966a561"
dependencies = [
"cfg-if 1.0.0",
"libc",
"raw-window-handle 0.3.4",
"redox_syscall 0.2.16",
"redox_syscall 0.3.5",
"sdl2",
"sdl2-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
@@ -1009,7 +944,7 @@ dependencies = [
"instant",
"libc",
"redox_syscall 0.2.16",
"smallvec 1.10.0",
"smallvec 1.11.0",
"winapi 0.3.9",
]
@@ -1025,9 +960,9 @@ dependencies = [
[[package]]
name = "paste"
version = "1.0.13"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "paw"
@@ -1062,7 +997,7 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5827dfa0d69b6c92493d6c38e633bbaa5937c153d0d7c28bf12313f8c6d514"
dependencies = [
"crossbeam-channel 0.5.7",
"crossbeam-channel 0.5.8",
"libc",
"winapi 0.3.9",
]
@@ -1074,6 +1009,7 @@ dependencies = [
"bincode",
"bitflags 1.2.1",
"byteorder 1.4.3",
"common",
"libc",
"log",
"paw",
@@ -1082,7 +1018,7 @@ dependencies = [
"redox_syscall 0.3.5",
"serde",
"serde_json",
"smallvec 1.10.0",
"smallvec 1.11.0",
"structopt",
"thiserror",
"toml 0.5.11",
@@ -1104,9 +1040,9 @@ checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
[[package]]
name = "pin-project-lite"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57"
[[package]]
name = "pin-utils"
@@ -1146,9 +1082,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.63"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [
"unicode-ident",
]
@@ -1165,9 +1101,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.26"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0"
dependencies = [
"proc-macro2",
]
@@ -1307,25 +1243,6 @@ dependencies = [
"vte",
]
[[package]]
name = "raw-window-handle"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76"
dependencies = [
"libc",
"raw-window-handle 0.4.3",
]
[[package]]
name = "raw-window-handle"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
[[package]]
name = "rdrand"
version = "0.4.0"
@@ -1353,7 +1270,7 @@ checksum = "cbf6d33a003a5c0b94ec11f10c7c797303f236592964ddb1bfb93e1b438a1557"
dependencies = [
"chrono",
"log",
"smallvec 1.10.0",
"smallvec 1.11.0",
"termion",
]
@@ -1397,6 +1314,7 @@ name = "rtl8139d"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"log",
"netutils",
"pcid",
@@ -1411,6 +1329,7 @@ name = "rtl8168d"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"log",
"netutils",
"pcid",
@@ -1439,15 +1358,16 @@ dependencies = [
[[package]]
name = "ryu"
version = "1.0.13"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "sb16d"
version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"common",
"log",
"redox-daemon",
"redox-log",
@@ -1458,15 +1378,9 @@ dependencies = [
[[package]]
name = "scopeguard"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scratch"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "scroll"
@@ -1497,7 +1411,6 @@ dependencies = [
"bitflags 1.2.1",
"lazy_static",
"libc",
"raw-window-handle 0.4.3",
"sdl2-sys",
]
@@ -1508,36 +1421,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0"
dependencies = [
"cfg-if 1.0.0",
"cmake",
"libc",
"version-compare",
]
[[package]]
name = "serde"
version = "1.0.159"
version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065"
checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.159"
version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585"
checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.13",
"syn 2.0.26",
]
[[package]]
name = "serde_json"
version = "1.0.95"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744"
checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b"
dependencies = [
"itoa",
"ryu",
@@ -1546,9 +1458,9 @@ dependencies = [
[[package]]
name = "serde_spanned"
version = "0.6.1"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186"
dependencies = [
"serde",
]
@@ -1573,9 +1485,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.10.0"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
dependencies = [
"serde",
]
@@ -1672,9 +1584,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.13"
version = "2.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec"
checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970"
dependencies = [
"proc-macro2",
"quote",
@@ -1687,15 +1599,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "termcolor"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
dependencies = [
"winapi-util",
]
[[package]]
name = "termion"
version = "1.5.6"
@@ -1719,22 +1622,22 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.40"
version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.40"
version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.13",
"syn 2.0.26",
]
[[package]]
@@ -1774,9 +1677,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.7.3"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21"
checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
dependencies = [
"serde",
"serde_spanned",
@@ -1786,18 +1689,18 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.6.1"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.8"
version = "0.19.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13"
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
dependencies = [
"indexmap",
"serde",
@@ -1814,9 +1717,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
[[package]]
name = "unicode-ident"
version = "1.0.8"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "unicode-normalization"
@@ -1908,6 +1811,7 @@ checksum = "2cb3ff47e36907a6267572c1e398ff32ef78ac5131de8aa272e53846592c207e"
name = "vboxd"
version = "0.1.0"
dependencies = [
"common",
"orbclient",
"redox-daemon",
"redox_event",
@@ -1936,6 +1840,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
name = "vesad"
version = "0.1.0"
dependencies = [
"common",
"inputd",
"orbclient",
"ransid",
@@ -1950,6 +1855,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"block-io-wrapper",
"common",
"futures",
"log",
"partitionlib",
@@ -1966,7 +1872,8 @@ dependencies = [
name = "virtio-core"
version = "0.1.0"
dependencies = [
"bitflags 2.3.2",
"bitflags 2.3.3",
"common",
"crossbeam-queue",
"futures",
"log",
@@ -1983,6 +1890,7 @@ name = "virtio-gpud"
version = "0.1.0"
dependencies = [
"anyhow",
"common",
"futures",
"inputd",
"log",
@@ -2027,9 +1935,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasm-bindgen"
version = "0.2.84"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@@ -2037,24 +1945,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.84"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.26",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.84"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2062,32 +1970,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.84"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.26",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.84"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
[[package]]
name = "web-sys"
version = "0.3.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
dependencies = [
"js-sys",
"wasm-bindgen",
]
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
[[package]]
name = "winapi"
@@ -2117,15 +2015,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@@ -2143,9 +2032,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.0"
version = "0.48.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@@ -2200,9 +2089,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "winnow"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28"
checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7"
dependencies = [
"memchr",
]
@@ -2232,6 +2121,7 @@ version = "0.1.0"
dependencies = [
"bitflags 1.2.1",
"chashmap",
"common",
"crossbeam-channel 0.4.4",
"futures",
"lazy_static",
@@ -2244,7 +2134,7 @@ dependencies = [
"redox_syscall 0.3.5",
"serde",
"serde_json",
"smallvec 1.10.0",
"smallvec 1.11.0",
"thiserror",
"toml 0.5.11",
]
+1
View File
@@ -6,6 +6,7 @@ members = [
"alxd",
"bgad",
"block-io-wrapper",
"common",
"e1000d",
"ided",
"ihdad",
+8 -4
View File
@@ -56,14 +56,18 @@ Missing class drivers for various classes.
- virtio-netd - VirtIO net device (incomplete).
- xhcid - xHCI (incomplete).
## Kernel Functions
## Kernel Interfaces
These are the most used kernel functions by Redox drivers.
These are the most used kernel interfaces by Redox drivers.
- `iopl` - syscall that sets the I/O privilege level. x86 has four privilege rings (0/1/2/3), of which the kernel runs in ring 0 and userspace in ring 3. IOPL can only be changed by the kernel, for obvious security reasons, and therefore the Redox kernel needs root to set it. It is unique for each process. Processes with IOPL=3 can access I/O ports, and the kernel can access them as well.
- `physalloc` - allocates physical memory frames.
- `physfree` - frees memory frames.
- `physmap` - maps physical memory frames to driver-accessible virtual memory pages.
- `memory:physical` - allows mapping physical memory frames to driver-accessible virtual memory pages, with various available memory types:
- `memory:physical`: default memory type (currently writeback)
- `memory:physical@wb` writeback cached memory
- `memory:physical@uc`: uncacheable memory
- `memory:physical@wc`: write-combining memory
- `irq:` - allows getting events from interrupts. It is used primarily by listening for its file descriptors using the `event:` scheme.
## Contributing to Drivers
@@ -74,4 +78,4 @@ If you don't have datasheets, we recommend you to do reverse-engineering of avai
We recommend BSDs drivers because BSD license is compatible with MIT (permissive), that way we can reuse the code in other drivers.
You can see this [example](https://gitlab.redox-os.org/redox-os/exampled) driver, read the code of the existent ones or the most close driver type for your device.
You can see this [example](https://gitlab.redox-os.org/redox-os/exampled) driver, read the code of the existent ones or the most close driver type for your device.
+1
View File
@@ -5,6 +5,7 @@ edition = "2018"
[dependencies]
bitflags = "1"
common = { path = "../common" }
log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
+2 -1
View File
@@ -5,9 +5,10 @@ use std::collections::BTreeMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::error::{Error, EACCES, EBADF, Result, EINVAL, ENOENT};
use syscall::io::{Dma, PhysBox, Mmio, Pio, Io};
use syscall::io::{Mmio, Pio, Io};
use syscall::scheme::SchemeBlockMut;
use common::dma::{Dma, PhysBox};
use spin::Mutex;
const NUM_SUB_BUFFS: usize = 32;
+3 -1
View File
@@ -19,4 +19,6 @@ redox_syscall = "0.3"
rustc-hash = "1.1.0"
thiserror = "1"
serde_json = "1.0.94"
amlserde = { path = "../amlserde" }
amlserde = { path = "../amlserde" }
common = { path = "../common" }
+1 -3
View File
@@ -5,8 +5,6 @@ use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::{fmt, mem};
use syscall::flag::PhysmapFlags;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use syscall::io::{Io, Pio};
@@ -106,7 +104,7 @@ impl PhysmapGuard {
fn map(page: usize, page_count: usize) -> std::io::Result<Self> {
let size = page_count * PAGE_SIZE;
let virt = unsafe {
syscall::call::physmap(page, size, PhysmapFlags::empty())
common::physmap(page, size, common::Prot::RO, common::MemoryType::default())
.map_err(|error| std::io::Error::from_raw_os_error(error.errno))?
};
+1 -1
View File
@@ -14,7 +14,7 @@ impl DrhdPage {
// TODO: Uncachable? Can reads have side-effects?
let virt = unsafe {
syscall::physmap(base_phys, crate::acpi::PAGE_SIZE, syscall::PhysmapFlags::PHYSMAP_WRITE)?
common::physmap(base_phys, crate::acpi::PAGE_SIZE, common::Prot::RO, common::MemoryType::default())?
} as *mut Drhd;
Ok(Self { virt })
+3 -3
View File
@@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
use std::fmt::LowerHex;
use std::mem::size_of;
use std::sync::{Arc, Mutex};
use syscall::{Io, PhysmapFlags, Pio, PAGE_SIZE};
use syscall::{Io, Pio, PAGE_SIZE};
const PAGE_MASK: usize = !(PAGE_SIZE - 1);
const OFFSET_MASK: usize = PAGE_SIZE - 1;
@@ -16,9 +16,9 @@ struct MappedPage {
impl MappedPage {
fn new(phys_page: usize) -> std::io::Result<Self> {
let virt_page = unsafe {
syscall::physmap(phys_page, PAGE_SIZE, PhysmapFlags::empty())
common::physmap(phys_page, PAGE_SIZE, common::Prot::RO, common::MemoryType::default())
.map_err(|error| std::io::Error::from_raw_os_error(error.errno))?
};
} as usize;
Ok(Self {
phys_page,
virt_page,
+2
View File
@@ -11,4 +11,6 @@ partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
redox-daemon = "0.1"
redox-log = "0.1"
redox_syscall = "0.3"
block-io-wrapper = { path = "../block-io-wrapper" }
common = { path = "../common" }
+2 -1
View File
@@ -1,9 +1,10 @@
use std::convert::TryInto;
use std::ptr;
use syscall::io::Dma;
use syscall::error::Result;
use common::dma::Dma;
use super::hba::{HbaPort, HbaCmdTable, HbaCmdHeader};
use super::Disk;
+2 -1
View File
@@ -5,9 +5,10 @@ use std::ptr;
use byteorder::{ByteOrder, BigEndian};
use syscall::io::Dma;
use syscall::error::{Result, EBADF, Error};
use common::dma::Dma;
use super::hba::{HbaPort, HbaCmdTable, HbaCmdHeader};
use super::Disk;
+3 -1
View File
@@ -3,11 +3,13 @@ use std::mem::size_of;
use std::ops::DerefMut;
use std::{ptr, u32};
use syscall::io::{Dma, Io, Mmio};
use syscall::io::{Io, Mmio};
use syscall::error::{Error, Result, EIO};
use super::fis::{FisType, FisRegH2D};
use common::dma::Dma;
const ATA_CMD_READ_DMA_EXT: u8 = 0x25;
const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35;
const ATA_CMD_IDENTIFY: u8 = 0xEC;
+8 -5
View File
@@ -9,10 +9,9 @@ use std::fs::File;
use std::io::{ErrorKind, Read, Write};
use std::os::unix::io::{FromRawFd, RawFd};
use syscall::PAGE_SIZE;
use syscall::error::{Error, ENODEV};
use syscall::data::{Event, Packet};
use syscall::flag::{EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::flag::EVENT_READ;
use syscall::scheme::SchemeBlockMut;
use log::{error, info};
@@ -91,8 +90,12 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
info!(" + AHCI {} on: {:X} size: {} IRQ: {}", name, bar, bar_size, irq);
let address = unsafe {
syscall::physmap(bar, bar_size.next_multiple_of(PAGE_SIZE), PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ahcid: failed to map address")
common::physmap(
bar,
bar_size,
common::Prot { read: true, write: true },
common::MemoryType::Uncacheable,
).expect("ahcid: failed to map address")
};
{
let scheme_name = format!("disk/{}", name);
@@ -126,7 +129,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
data: 0
}).expect("ahcid: failed to event irq scheme");
let (hba_mem, disks) = ahci::disks(address, &name);
let (hba_mem, disks) = ahci::disks(address as usize, &name);
let mut scheme = DiskScheme::new(scheme_name, hba_mem, disks);
let mut mounted = true;
+2
View File
@@ -9,3 +9,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch =
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.3"
redox-daemon = "0.1"
common = { path = "../common" }
+4 -2
View File
@@ -1,12 +1,14 @@
use std::{ptr, thread, time};
use std::convert::TryInto;
use netutils::setcfg;
use syscall::error::{Error, EACCES, EINVAL, EIO, EWOULDBLOCK, Result};
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::{Dma, Io, Mmio};
use syscall::io::{Io, Mmio};
use syscall::scheme;
use common::dma::Dma;
use netutils::setcfg;
use self::regs::*;
mod regs;
+2 -2
View File
@@ -15,7 +15,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{EventFlags, Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{EventFlags, Packet, SchemeMut};
use syscall::error::EWOULDBLOCK;
pub mod device;
@@ -43,7 +43,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("alxd: failed to open IRQ file");
let address = unsafe { syscall::physmap(bar, 128*1024, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("alxd: failed to map address") };
let address = unsafe { common::physmap(bar, 128*1024, common::Prot::RW, common::MemoryType::Uncacheable).expect("alxd: failed to map address") as usize };
{
let device = Arc::new(RefCell::new(unsafe { device::Alx::new(address).expect("alxd: failed to allocate device") }));
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "common"
version = "0.1.0"
edition = "2021"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
redox_syscall = "0.3"
+217
View File
@@ -0,0 +1,217 @@
use std::mem::{self, MaybeUninit};
use std::ops::{Deref, DerefMut};
use std::{ptr, slice};
use syscall::PAGE_SIZE;
use syscall::Result;
use syscall::{PartialAllocStrategy, PhysallocFlags};
use crate::MemoryType;
/// An RAII guard of a physical memory allocation. Currently all physically allocated memory are
/// page-aligned and take up at least 4k of space (on x86_64).
#[derive(Debug)]
pub struct PhysBox {
address: usize,
size: usize
}
fn assert_aligned(x: usize) {
assert_eq!(x % PAGE_SIZE, 0);
}
const DMA_MEMTY: MemoryType = {
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
// aarch64 currently must map DMA memory without caching to ensure coherence
MemoryType::Writeback
} else if cfg!(target_arch = "aarch64") {
// x86 ensures cache coherence with DMA memory
MemoryType::Uncacheable
} else {
panic!("invalid arch")
}
};
impl PhysBox {
/// Construct a PhysBox from an address and a size. The address must be page-aligned, and the
/// size must similarly be a multiple of the page size.
///
/// # Safety
/// This function is unsafe because when dropping, Self has to a valid allocation.
pub unsafe fn from_raw_parts(address: usize, size: usize) -> Self {
assert_aligned(address);
assert_aligned(size);
Self {
address,
size,
}
}
/// Retrieve the byte address in physical memory, of this allocation.
pub fn address(&self) -> usize {
self.address
}
/// Retrieve the size in bytes of the alloc.
pub fn size(&self) -> usize {
self.size
}
/// Allocate physical memory that must reside in 32-bit space.
pub fn new_in_32bit_space(size: usize) -> Result<Self> {
Self::new_with_flags(size, PhysallocFlags::SPACE_32)
}
pub fn new_with_flags(size: usize, flags: PhysallocFlags) -> Result<Self> {
assert!(!flags.contains(PhysallocFlags::PARTIAL_ALLOC));
assert_aligned(size);
let address = unsafe { syscall::physalloc2(size, flags.bits())? };
Ok(unsafe { Self::from_raw_parts(address, size) })
}
/// "Partially" allocate physical memory, in the sense that the allocation may be smaller than
/// expected, but still with a minimum limit. This is particularly useful when the physical
/// memory space is fragmented, and a device supports scatter-gather I/O. In that case, the
/// driver can optimistically request e.g. 1 alloc of 1 MiB, with the minimum of 512 KiB. If
/// that first allocation only returns half the size, the driver can do another allocation
/// and then let the device use both buffers.
pub fn new_partial_allocation(size: usize, flags: PhysallocFlags, strategy: Option<PartialAllocStrategy>, mut min: usize) -> Result<Self> {
assert_aligned(size);
debug_assert!(!(flags.contains(PhysallocFlags::PARTIAL_ALLOC) && strategy.is_none()));
let address = unsafe { syscall::physalloc3(size, flags.bits() | strategy.map_or(0, |s| s as usize), &mut min)? };
Ok(unsafe { Self::from_raw_parts(address, size) })
}
pub fn new(size: usize) -> Result<Self> {
assert_aligned(size);
let address = unsafe { syscall::physalloc(size)? };
Ok(unsafe { Self::from_raw_parts(address, size) })
}
}
impl Drop for PhysBox {
fn drop(&mut self) {
let _ = unsafe { syscall::physfree(self.address, self.size) };
}
}
pub struct Dma<T: ?Sized> {
phys: PhysBox,
virt: *mut T,
}
impl<T> Dma<T> {
pub fn from_physbox_uninit(phys: PhysBox) -> Result<Dma<MaybeUninit<T>>> {
Ok(Dma {
virt: unsafe { crate::physmap(phys.address, phys.size, crate::Prot::RW, DMA_MEMTY)? } as *mut MaybeUninit<T>,
phys,
})
}
pub fn from_physbox_zeroed(phys: PhysBox) -> Result<Dma<MaybeUninit<T>>> {
let this = Self::from_physbox_uninit(phys)?;
unsafe { ptr::write_bytes(this.virt as *mut MaybeUninit<u8>, 0, this.phys.size) }
Ok(this)
}
pub fn from_physbox(phys: PhysBox, value: T) -> Result<Self> {
let this = Self::from_physbox_uninit(phys)?;
Ok(unsafe {
ptr::write(this.virt, MaybeUninit::new(value));
this.assume_init()
})
}
pub fn new(value: T) -> Result<Self> {
let phys = PhysBox::new(mem::size_of::<T>().next_multiple_of(PAGE_SIZE))?;
Self::from_physbox(phys, value)
}
pub fn zeroed() -> Result<Dma<MaybeUninit<T>>> {
let phys = PhysBox::new(mem::size_of::<T>().next_multiple_of(PAGE_SIZE))?;
Self::from_physbox_zeroed(phys)
}
}
impl<T> Dma<MaybeUninit<T>> {
pub unsafe fn assume_init(self) -> Dma<T> {
let &Dma { phys: PhysBox { address, size }, virt } = &self;
mem::forget(self);
Dma {
phys: PhysBox { address, size },
virt: virt as *mut T,
}
}
}
impl<T: ?Sized> Dma<T> {
pub fn physical(&self) -> usize {
self.phys.address()
}
pub fn size(&self) -> usize {
self.phys.size()
}
pub fn phys(&self) -> &PhysBox {
&self.phys
}
}
impl<T> Dma<[T]> {
pub fn from_physbox_uninit_unsized(phys: PhysBox, len: usize) -> Result<Dma<[MaybeUninit<T>]>> {
let max_len = phys.size() / mem::size_of::<T>();
assert!(len <= max_len);
Ok(Dma {
virt: unsafe { slice::from_raw_parts_mut(crate::physmap(phys.address, phys.size, crate::Prot::RW, DMA_MEMTY)? as *mut MaybeUninit<T>, len) } as *mut [MaybeUninit<T>],
phys,
})
}
pub fn from_physbox_zeroed_unsized(phys: PhysBox, len: usize) -> Result<Dma<[MaybeUninit<T>]>> {
let this = Self::from_physbox_uninit_unsized(phys, len)?;
unsafe { ptr::write_bytes(this.virt as *mut MaybeUninit<u8>, 0, this.phys.size()) }
Ok(this)
}
/// Creates a new DMA buffer with a size only known at runtime.
/// ## Safety
/// * `T` must be properly aligned.
/// * `T` must be valid as zeroed (i.e. no NonNull pointers).
pub unsafe fn zeroed_unsized(count: usize) -> Result<Self> {
let phys = PhysBox::new((mem::size_of::<T>() * count).next_multiple_of(PAGE_SIZE))?;
Ok(Self::from_physbox_zeroed_unsized(phys, count)?.assume_init())
}
}
impl<T> Dma<[MaybeUninit<T>]> {
pub unsafe fn assume_init(self) -> Dma<[T]> {
let &Dma { phys: PhysBox { address, size }, virt } = &self;
mem::forget(self);
Dma {
phys: PhysBox { address, size },
virt: virt as *mut [T],
}
}
}
impl<T: ?Sized> Deref for Dma<T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.virt }
}
}
impl<T: ?Sized> DerefMut for Dma<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.virt }
}
}
impl<T: ?Sized> Drop for Dma<T> {
fn drop(&mut self) {
unsafe { ptr::drop_in_place(self.virt) }
let _ = unsafe { syscall::funmap(self.virt as *mut u8 as usize, self.phys.size) };
}
}
+59
View File
@@ -0,0 +1,59 @@
#![feature(int_roundings)]
use syscall::PAGE_SIZE;
use syscall::error::{Error, Result, EINVAL};
use syscall::flag::{MapFlags, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
pub mod dma;
#[derive(Clone, Copy, Debug)]
pub enum MemoryType {
Writeback,
Uncacheable,
WriteCombining,
}
impl Default for MemoryType {
fn default() -> Self {
Self::Writeback
}
}
#[derive(Clone, Copy, Debug)]
pub struct Prot {
pub read: bool,
pub write: bool,
}
impl Prot {
pub const RO: Self = Self { read: true, write: false };
pub const WO: Self = Self { read: false, write: true };
pub const RW: Self = Self { read: true, write: true };
}
pub unsafe fn physmap(base_phys: usize, len: usize, Prot { read, write }: Prot, ty: MemoryType) -> Result<*mut ()> {
// TODO: arraystring?
let path = format!("memory:physical@{}", match ty {
MemoryType::Writeback => "wb",
MemoryType::Uncacheable => "uc",
MemoryType::WriteCombining => "wc",
});
let mode = match (read, write) {
(true, true) => O_RDWR,
(true, false) => O_RDONLY,
(false, true) => O_WRONLY,
(false, false) => return Err(Error::new(EINVAL)),
};
let mut prot = MapFlags::empty();
prot.set(MapFlags::PROT_READ, read);
prot.set(MapFlags::PROT_WRITE, write);
let file = syscall::open(path, O_CLOEXEC | mode)?;
let base = syscall::fmap(file, &syscall::Map {
offset: base_phys,
size: len.next_multiple_of(PAGE_SIZE),
flags: MapFlags::MAP_SHARED | prot,
address: 0,
});
let _ = syscall::close(file);
Ok(base? as *mut ())
}
+2
View File
@@ -9,3 +9,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch =
redox-daemon = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.3"
common = { path = "../common" }
+2 -1
View File
@@ -6,9 +6,10 @@ use netutils::setcfg;
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, EWOULDBLOCK};
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::Dma;
use syscall::scheme::SchemeBlockMut;
use common::dma::Dma;
const CTRL: u32 = 0x00;
const CTRL_LRST: u32 = 1 << 3;
const CTRL_ASDE: u32 = 1 << 5;
+3 -3
View File
@@ -10,7 +10,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{EventFlags, Packet, SchemeBlockMut};
pub mod device;
@@ -91,9 +91,9 @@ fn main() {
let mut irq_file = unsafe { File::from_raw_fd(irq_fd as RawFd) };
let address = unsafe {
syscall::physmap(bar, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
common::physmap(bar, bar_size, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("e1000d: failed to map address")
};
} as usize;
{
let device = Arc::new(RefCell::new(unsafe {
device::Intel8254x::new(address).expect("e1000d: failed to allocate device")
+1
View File
@@ -5,6 +5,7 @@ edition = "2018"
[dependencies]
block-io-wrapper = { path = "../block-io-wrapper" }
common = { path = "../common" }
log = "0.4"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
pcid = { path = "../pcid" }
+4 -1
View File
@@ -4,11 +4,14 @@ use std::{
thread,
time::{Duration, Instant},
};
use syscall::{
error::{Error, Result, EIO},
io::{Dma, Io, Pio, PhysBox, ReadOnly, WriteOnly},
io::{Io, Pio, ReadOnly, WriteOnly},
};
use common::dma::{Dma, PhysBox};
static TIMEOUT: Duration = Duration::new(1, 0);
#[repr(u8)]
+1
View File
@@ -12,4 +12,5 @@ redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.3"
spin = "0.9"
common = { path = "../common" }
pcid = { path = "../pcid" }
+3 -4
View File
@@ -7,7 +7,6 @@ use std::str;
use std::collections::BTreeMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::error::{Error, EACCES, EBADF, Result, EINVAL};
use syscall::flag::{SEEK_SET, SEEK_CUR, SEEK_END};
use syscall::io::{Mmio, Io};
@@ -159,8 +158,8 @@ impl IntelHDA {
.expect("Could not allocate physical memory for buffer descriptor list.");
let buff_desc_virt =
syscall::physmap(buff_desc_phys, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ihdad: failed to map address for buffer descriptor list.");
common::physmap(buff_desc_phys, 0x1000, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("ihdad: failed to map address for buffer descriptor list.") as usize;
log::debug!("Virt: {:016X}, Phys: {:016X}", buff_desc_virt, buff_desc_phys);
@@ -170,7 +169,7 @@ impl IntelHDA {
syscall::physalloc(0x1000)
.expect("Could not allocate physical memory for CORB and RIRB.");
let cmd_buff_virt = syscall::physmap(cmd_buff_address, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("ihdad: failed to map address for CORB/RIRB buff");
let cmd_buff_virt = common::physmap(cmd_buff_address, 0x1000, common::Prot::RW, common::MemoryType::Uncacheable).expect("ihdad: failed to map address for CORB/RIRB buff") as usize;
log::debug!("Virt: {:016X}, Phys: {:016X}", cmd_buff_virt, cmd_buff_address);
let mut module = IntelHDA {
+3 -3
View File
@@ -1,4 +1,4 @@
use syscall::{PHYSMAP_WRITE, PHYSMAP_NO_CACHE, PAGE_SIZE};
use syscall::PAGE_SIZE;
use syscall::error::{Error, EIO, Result};
use syscall::io::{Mmio, Io};
use std::result;
@@ -301,9 +301,9 @@ impl StreamBuffer {
};
let addr = match unsafe {
syscall::physmap(phys, page_aligned_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
common::physmap(phys, page_aligned_size, common::Prot::RW, common::MemoryType::Uncacheable)
} {
Ok(addr) => addr,
Ok(ptr) => ptr as usize,
Err(_err) => {
unsafe {
syscall::physfree(phys, page_aligned_size);
+3 -3
View File
@@ -11,7 +11,7 @@ use std::usize;
use std::fs::File;
use std::io::{ErrorKind, Read, Write, Result};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Packet, SchemeBlockMut, EventFlags};
use syscall::{Packet, SchemeBlockMut, EventFlags};
use std::cell::RefCell;
use std::sync::Arc;
@@ -177,8 +177,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
log::info!(" + IHDA {} on: {:#X} size: {}", name, bar_ptr, bar_size);
let address = unsafe {
syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ihdad: failed to map address")
common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("ihdad: failed to map address") as usize
};
//TODO: MSI-X
+2
View File
@@ -8,3 +8,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch =
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.3"
redox-daemon = "0.1"
common = { path = "../common" }
+3 -2
View File
@@ -3,12 +3,13 @@ use std::convert::TryInto;
use std::time::{Duration, Instant};
use std::{cmp, mem, ptr, slice, thread};
use netutils::setcfg;
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, EWOULDBLOCK};
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::Dma;
use syscall::scheme::SchemeBlockMut;
use common::dma::Dma;
use netutils::setcfg;
use ixgbe::*;
pub struct Intel8259x {
+6 -3
View File
@@ -2,6 +2,9 @@ extern crate event;
extern crate netutils;
extern crate syscall;
// TODO: Migrate to Rust 2018/2021
extern crate common;
use std::cell::RefCell;
use std::fs::File;
use std::io::{ErrorKind, Read, Result, Write};
@@ -11,7 +14,7 @@ use std::{env, thread};
use event::EventQueue;
use std::time::Duration;
use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{EventFlags, Packet, SchemeBlockMut};
pub mod device;
#[rustfmt::skip]
@@ -92,8 +95,8 @@ fn main() {
File::open(format!("irq:{}", irq)).expect("ixgbed: failed to open IRQ file");
let address = unsafe {
syscall::physmap(bar, IXGBE_MMIO_SIZE, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ixgbed: failed to map address")
common::physmap(bar, IXGBE_MMIO_SIZE, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("ixgbed: failed to map address") as usize
};
{
let device = Arc::new(RefCell::new(
+2 -1
View File
@@ -14,8 +14,9 @@ redox-log = "0.1"
redox_syscall = "0.3"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
smallvec = "1"
block-io-wrapper = { path = "../block-io-wrapper" }
block-io-wrapper = { path = "../block-io-wrapper" }
common = { path = "../common" }
pcid = { path = "../pcid" }
[features]
+12 -6
View File
@@ -11,8 +11,8 @@ use std::{slice, usize};
use pcid_interface::{PciBar, PciFeature, PciFeatureInfo, PciFunction, PcidServerHandle};
use syscall::{
Event, Mmio, Packet, Result, SchemeBlockMut, PHYSMAP_NO_CACHE,
PHYSMAP_WRITE, PAGE_SIZE,
Event, Mmio, Packet, Result, SchemeBlockMut,
PAGE_SIZE,
};
use redox_log::{OutputBuilder, RedoxLogger};
@@ -32,7 +32,12 @@ impl Bar {
pub fn allocate(bar: usize, bar_size: usize) -> Result<Self> {
Ok(Self {
ptr: NonNull::new(
unsafe { syscall::physmap(bar, bar_size, PHYSMAP_NO_CACHE | PHYSMAP_WRITE)? as *mut u8 },
unsafe { common::physmap(
bar,
bar_size,
common::Prot { read: true, write: true },
common::MemoryType::Uncacheable,
)? as *mut u8 },
)
.expect("Mapping a BAR resulted in a nullptr"),
physical: bar,
@@ -318,13 +323,14 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let allocated_bars = AllocatedBars::default();
let address = unsafe {
syscall::physmap(
common::physmap(
bar as usize,
bar_size as usize,
PHYSMAP_WRITE | PHYSMAP_NO_CACHE,
common::Prot { read: true, write: true },
common::MemoryType::Uncacheable,
)
.expect("nvmed: failed to map address")
};
} as usize;
*allocated_bars.0[0].lock().unwrap() = Some(Bar {
physical: bar as usize,
bar_size: bar_size as usize,
+2 -2
View File
@@ -1,7 +1,7 @@
use syscall::Dma;
use super::{Nvme, NvmeCmd, NvmeNamespace};
use common::dma::Dma;
/// See NVME spec section 5.15.2.2.
#[derive(Clone, Copy)]
#[repr(packed)]
+3 -1
View File
@@ -10,7 +10,9 @@ use crossbeam_channel::Sender;
use smallvec::{smallvec, SmallVec};
use syscall::error::{Error, Result, EINVAL, EIO};
use syscall::io::{Dma, Io, Mmio};
use syscall::io::{Io, Mmio};
use common::dma::Dma;
pub mod cmd;
pub mod cq_reactor;
+3 -1
View File
@@ -1,5 +1,7 @@
use std::ptr;
use syscall::{Dma, Result};
use syscall::Result;
use common::dma::Dma;
/// A submission queue entry.
#[derive(Clone, Copy, Debug, Default)]
+2
View File
@@ -27,3 +27,5 @@ smallvec = "1"
structopt = { version = "0.3", default-features = false, features = [ "paw" ] }
thiserror = "1"
toml = "0.5"
common = { path = "../common" }
+8 -2
View File
@@ -3,7 +3,6 @@ use std::collections::BTreeMap;
use std::sync::{Arc, Mutex};
use syscall::PAGE_SIZE;
use syscall::flag::PhysmapFlags;
use smallvec::SmallVec;
@@ -173,7 +172,14 @@ impl Pcie {
};
let mut maps_lock = self.maps.lock().unwrap();
let virt_pointer = maps_lock.entry((bus, dev, func)).or_insert_with(|| {
syscall::physmap(base_address_phys as usize + Self::addr_offset_in_bytes(starting_bus, bus, dev, func, 0), PAGE_SIZE, PhysmapFlags::PHYSMAP_NO_CACHE | PhysmapFlags::PHYSMAP_WRITE).unwrap_or_else(|error| panic!("failed to physmap pcie configuration space for {:2x}:{:2x}.{:2x}: {:?}", bus, dev, func, error)) as *mut u32
common::physmap(
base_address_phys as usize + Self::addr_offset_in_bytes(starting_bus, bus, dev, func, 0),
PAGE_SIZE,
common::Prot { read: true, write: true },
common::MemoryType::Uncacheable,
).unwrap_or_else(|error| {
panic!("failed to physmap pcie configuration space for {:2x}:{:2x}.{:2x}: {:?}", bus, dev, func, error)
}) as *mut u32
});
f(Some(&mut *virt_pointer.offset((offset as usize / mem::size_of::<u32>()) as isize)))
}
+1
View File
@@ -12,4 +12,5 @@ redox_syscall = "0.3"
redox-daemon = "0.1"
redox-log = "0.1"
common = { path = "../common" }
pcid = { path = "../pcid" }
+4 -2
View File
@@ -2,12 +2,14 @@ use std::mem;
use std::convert::TryInto;
use std::collections::BTreeMap;
use netutils::setcfg;
use syscall::error::{Error, EACCES, EBADF, EINVAL, EIO, EMSGSIZE, EWOULDBLOCK, Result};
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::{Dma, Mmio, Io, ReadOnly};
use syscall::io::{Mmio, Io, ReadOnly};
use syscall::scheme::SchemeBlockMut;
use common::dma::Dma;
use netutils::setcfg;
const RX_BUFFER_SIZE: usize = 64 * 1024;
const RXSTS_ROK: u16 = 1 << 0;
+5 -5
View File
@@ -18,7 +18,7 @@ use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeature
use pcid_interface::irq_helpers::{read_bsp_apic_id, allocate_single_interrupt_vector};
use pcid_interface::msi::{MsixCapability, MsixTableEntry};
use redox_log::{RedoxLogger, OutputBuilder};
use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{EventFlags, Packet, SchemeBlockMut};
use syscall::io::Io;
pub mod device;
@@ -187,8 +187,8 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option<File> {
};
let address = unsafe {
syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("rtl8139d: failed to map address")
common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("rtl8139d: failed to map address") as usize
};
if !(bar_ptr..bar_ptr + bar_size).contains(&(table_base as u64 + table_min_length as u64)) {
@@ -345,8 +345,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
log::info!(" + RTL8139 {} on: {:#X} size: {}", name, bar_ptr, bar_size);
let address = unsafe {
syscall::physmap(bar_ptr, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("rtl8139d: failed to map address")
common::physmap(bar_ptr, bar_size, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("rtl8139d: failed to map address") as usize
};
let socket_fd = syscall::open(
+1
View File
@@ -12,4 +12,5 @@ redox_syscall = "0.3"
redox-daemon = "0.1"
redox-log = "0.1"
common = { path = "../common" }
pcid = { path = "../pcid" }
+4 -2
View File
@@ -5,12 +5,14 @@ use std::mem;
use std::convert::TryInto;
use std::collections::BTreeMap;
use netutils::setcfg;
use syscall::error::{Error, EACCES, EBADF, EINVAL, EMSGSIZE, EWOULDBLOCK, Result};
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::{Dma, Mmio, Io, ReadOnly};
use syscall::io::{Mmio, Io, ReadOnly};
use syscall::scheme::SchemeBlockMut;
use common::dma::Dma;
use netutils::setcfg;
#[repr(packed)]
struct Regs {
mac: [Mmio<u32>; 2],
+5 -5
View File
@@ -16,7 +16,7 @@ use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeature
use pcid_interface::irq_helpers::{read_bsp_apic_id, allocate_single_interrupt_vector};
use pcid_interface::msi::{MsixCapability, MsixTableEntry};
use redox_log::{RedoxLogger, OutputBuilder};
use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{EventFlags, Packet, SchemeBlockMut};
use syscall::io::Io;
pub mod device;
@@ -185,8 +185,8 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option<File> {
};
let address = unsafe {
syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("rtl8168d: failed to map address")
common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("rtl8168d: failed to map address") as usize
};
if !(bar_ptr..bar_ptr + bar_size).contains(&(table_base as u64 + table_min_length as u64)) {
@@ -343,8 +343,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
log::info!(" + RTL8168 {} on: {:#X} size: {}", name, bar_ptr, bar_size);
let address = unsafe {
syscall::physmap(bar_ptr, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("rtl8168d: failed to map address")
common::physmap(bar_ptr, bar_size, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("rtl8168d: failed to map address") as usize
};
let socket_fd = syscall::open(
+1
View File
@@ -5,6 +5,7 @@ edition = "2018"
[dependencies]
bitflags = "1"
common = { path = "../common" }
log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
+2 -1
View File
@@ -5,9 +5,10 @@ use std::collections::BTreeMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::error::{Error, EACCES, EBADF, Result, EINVAL, ENODEV, ENOENT};
use syscall::io::{Dma, PhysBox, Mmio, Pio, Io, ReadOnly, WriteOnly};
use syscall::io::{Mmio, Pio, Io, ReadOnly, WriteOnly};
use syscall::scheme::SchemeBlockMut;
use common::dma::{Dma, PhysBox};
use spin::Mutex;
const NUM_SUB_BUFFS: usize = 32;
+2
View File
@@ -8,3 +8,5 @@ orbclient = "0.3.27"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.3"
redox-daemon = "0.1"
common = { path = "../common" }
+5 -3
View File
@@ -11,8 +11,10 @@ use std::fs::File;
use std::io::{Result, Read, Write};
use syscall::call::iopl;
use syscall::flag::{EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::io::{Dma, Io, Mmio, Pio};
use syscall::flag::EventFlags;
use syscall::io::{Io, Mmio, Pio};
use common::dma::Dma;
use crate::bga::Bga;
@@ -220,7 +222,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("vboxd: failed to open IRQ file");
let mut port = Pio::<u32>::new(bar0 as u16);
let address = unsafe { syscall::physmap(bar1, 4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("vboxd: failed to map address") };
let address = unsafe { common::physmap(bar1, 4096, common::Prot::RW, common::MemoryType::Uncacheable).expect("vboxd: failed to map address") };
{
let vmmdev = unsafe { &mut *(address as *mut VboxVmmDev) };
+2
View File
@@ -9,6 +9,8 @@ ransid = "0.4"
rusttype = { version = "0.2", optional = true }
redox_syscall = "0.3"
redox-daemon = "0.1"
common = { path = "../common" }
inputd = { path = "../inputd" }
[features]
+3 -2
View File
@@ -46,10 +46,11 @@ impl FrameBuffer {
pub unsafe fn map(&mut self) -> syscall::Result<&'static mut [u32]> {
let size = self.stride * self.height;
let virt = syscall::physmap(
let virt = common::physmap(
self.phys,
size * 4,
syscall::PHYSMAP_WRITE | syscall::PHYSMAP_WRITE_COMBINE
common::Prot { read: true, write: true },
common::MemoryType::WriteCombining,
)? as *mut u32;
//TODO: should we clear the framebuffer here?
ptr::write_bytes(virt, 0, size);
+4 -3
View File
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::{mem, ptr, slice, str};
use orbclient::{Event, EventOption};
use syscall::{Error, EventFlags, EACCES, EBADF, EINVAL, ENOENT, Map, O_NONBLOCK, physmap, PHYSMAP_WRITE, PHYSMAP_WRITE_COMBINE, Result, SchemeMut, PAGE_SIZE};
use syscall::{Error, EventFlags, EACCES, EBADF, EINVAL, ENOENT, Map, O_NONBLOCK, Result, SchemeMut, PAGE_SIZE};
use crate::{
display::Display,
@@ -111,10 +111,11 @@ impl DisplayScheme {
// Map new onscreen
self.onscreens[fb_i] = unsafe {
let size = stride * height;
let onscreen_ptr = physmap(
let onscreen_ptr = common::physmap(
self.framebuffers[fb_i].phys,
size * 4,
PHYSMAP_WRITE | PHYSMAP_WRITE_COMBINE
common::Prot { read: true, write: true },
common::MemoryType::WriteCombining,
).expect("vesad: failed to map framebuffer") as *mut u32;
ptr::write_bytes(onscreen_ptr, 0, size);
+1
View File
@@ -17,5 +17,6 @@ redox_syscall = "0.3"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
block-io-wrapper = { path = "../block-io-wrapper" }
common = { path = "../common" }
pcid = { path = "../pcid" }
virtio-core = { path = "../virtio-core" }
+10 -9
View File
@@ -7,6 +7,7 @@ use std::io::Seek;
use std::fmt::Write;
use std::sync::Arc;
use common::dma::Dma;
use partitionlib::LogicalBlockSize;
use partitionlib::PartitionTable;
use syscall::*;
@@ -27,15 +28,15 @@ trait BlkExtension {
impl BlkExtension for Queue<'_> {
async fn read(&self, block: u64, target: &mut [u8]) -> usize {
let req = syscall::Dma::new(BlockVirtRequest {
let req = Dma::new(BlockVirtRequest {
ty: BlockRequestTy::In,
reserved: 0,
sector: block,
})
.unwrap();
let result = unsafe { syscall::Dma::<[u8]>::zeroed_unsized(target.len()) }.unwrap();
let status = syscall::Dma::new(u8::MAX).unwrap();
let result = unsafe { Dma::<[u8]>::zeroed_unsized(target.len()) }.unwrap();
let status = Dma::new(u8::MAX).unwrap();
let chain = ChainBuilder::new()
.chain(Buffer::new(&req))
@@ -52,17 +53,17 @@ impl BlkExtension for Queue<'_> {
}
async fn write(&self, block: u64, target: &[u8]) -> usize {
let req = syscall::Dma::new(BlockVirtRequest {
let req = Dma::new(BlockVirtRequest {
ty: BlockRequestTy::Out,
reserved: 0,
sector: block,
})
.unwrap();
let mut result = unsafe { syscall::Dma::<[u8]>::zeroed_unsized(target.len()) }.unwrap();
let mut result = unsafe { Dma::<[u8]>::zeroed_unsized(target.len()) }.unwrap();
result.copy_from_slice(target.as_ref());
let status = syscall::Dma::new(u8::MAX).unwrap();
let status = Dma::new(u8::MAX).unwrap();
let chain = ChainBuilder::new()
.chain(Buffer::new(&req))
@@ -122,15 +123,15 @@ impl<'a> DiskScheme<'a> {
impl<'a, 'b> Read for VirtioShim<'a, 'b> {
fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
let read_block = |block: u64, block_bytes: &mut [u8]| -> Result<(), ()> {
let req = syscall::Dma::new(BlockVirtRequest {
let req = Dma::new(BlockVirtRequest {
ty: BlockRequestTy::In,
reserved: 0,
sector: block,
})
.unwrap();
let result = syscall::Dma::new([0u8; 512]).unwrap();
let status = syscall::Dma::new(u8::MAX).unwrap();
let result = Dma::new([0u8; 512]).unwrap();
let status = Dma::new(u8::MAX).unwrap();
let chain = ChainBuilder::new()
.chain(Buffer::new(&req))
+1
View File
@@ -16,4 +16,5 @@ crossbeam-queue = "0.3.8"
redox-log = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
common = { path = "../common" }
pcid = { path = "../pcid" }
+6 -5
View File
@@ -8,7 +8,7 @@ use pcid_interface::msi::x86_64::DeliveryMode;
use pcid_interface::msi::{MsixCapability, MsixTableEntry};
use pcid_interface::*;
use syscall::{Io, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::Io;
use crate::spec::*;
use crate::transport::{Error, StandardTransport};
@@ -68,11 +68,12 @@ fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
};
let address = unsafe {
syscall::physmap(
common::physmap(
bar_ptr as usize,
bar_size as usize,
PHYSMAP_WRITE | PHYSMAP_NO_CACHE,
)?
common::Prot::RW,
common::MemoryType::Uncacheable,
)? as usize
};
// Ensure that the table and PBA are be within the BAR.
@@ -186,7 +187,7 @@ pub fn probe_device<'a>(pcid_handle: &mut PcidServerHandle) -> Result<Device<'a>
let size = offset + capability.length as usize;
let addr = syscall::physmap(aligned_addr, size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)?;
let addr = common::physmap(aligned_addr, size, common::Prot::RW, common::MemoryType::Uncacheable)? as usize;
addr + offset
};
+3 -3
View File
@@ -246,7 +246,7 @@ pub struct Buffer {
}
impl Buffer {
pub fn new<T>(val: &syscall::Dma<T>) -> Self {
pub fn new<T>(val: &common::dma::Dma<T>) -> Self {
Self {
buffer: val.physical(),
size: core::mem::size_of::<T>(),
@@ -254,7 +254,7 @@ impl Buffer {
}
}
pub fn new_unsized<T>(val: &syscall::Dma<[T]>) -> Self {
pub fn new_unsized<T>(val: &common::dma::Dma<[T]>) -> Self {
Self {
buffer: val.physical(),
size: core::mem::size_of::<T>() * val.len(),
@@ -262,7 +262,7 @@ impl Buffer {
}
}
pub fn new_sized<T>(val: &syscall::Dma<[T]>, size: usize) -> Self {
pub fn new_sized<T>(val: &common::dma::Dma<[T]>, size: usize) -> Self {
Self {
buffer: val.physical(),
size,
+7 -6
View File
@@ -1,8 +1,8 @@
use crate::spec::*;
use crate::utils::align;
use common::dma::Dma;
use event::EventQueue;
use syscall::{Dma, PHYSMAP_WRITE};
use core::mem::size_of;
use core::sync::atomic::{AtomicU16, Ordering};
@@ -230,8 +230,9 @@ impl<'a> Available<'a> {
let size = size.next_multiple_of(syscall::PAGE_SIZE); // align to page size
let addr = unsafe { syscall::physalloc(size) }.map_err(Error::SyscallError)?;
let virt =
unsafe { syscall::physmap(addr, size, PHYSMAP_WRITE) }.map_err(Error::SyscallError)?;
let virt = unsafe {
common::physmap(addr, size, common::Prot::RW, common::MemoryType::default())
}.map_err(Error::SyscallError)?;
let ring = unsafe { &mut *(virt as *mut AvailableRing) };
@@ -275,7 +276,7 @@ impl Drop for Available<'_> {
log::warn!("virtio-core: dropping 'available' ring at {:#x}", self.addr);
unsafe {
syscall::physunmap(self.addr).unwrap();
syscall::funmap(self.addr, self.size).unwrap();
syscall::physfree(self.addr, self.size).unwrap();
}
}
@@ -297,7 +298,7 @@ impl<'a> Used<'a> {
let addr = unsafe { syscall::physalloc(size) }.map_err(Error::SyscallError)?;
let virt =
unsafe { syscall::physmap(addr, size, PHYSMAP_WRITE) }.map_err(Error::SyscallError)?;
unsafe { common::physmap(addr, size, common::Prot::RW, common::MemoryType::default()) }.map_err(Error::SyscallError)?;
let ring = unsafe { &mut *(virt as *mut UsedRing) };
@@ -355,7 +356,7 @@ impl Drop for Used<'_> {
log::warn!("virtio-core: dropping 'used' ring at {:#x}", self.addr);
unsafe {
syscall::physunmap(self.addr).unwrap();
syscall::funmap(self.addr, self.size).unwrap();
syscall::physfree(self.addr, self.size).unwrap();
}
}
+1
View File
@@ -11,6 +11,7 @@ futures = { version = "0.3.28", features = ["executor"] }
anyhow = "1.0.71"
paste = "1.0.13"
common = { path = "../common" }
virtio-core = { path = "../virtio-core" }
pcid = { path = "../pcid" }
inputd = { path = "../inputd" }
+6 -4
View File
@@ -3,8 +3,9 @@ use std::collections::BTreeMap;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use common::dma::Dma;
use inputd::Damage;
use syscall::{Dma, Error as SysError, SchemeMut, EINVAL};
use syscall::{Error as SysError, SchemeMut, EINVAL};
use virtio_core::spec::{Buffer, ChainBuilder, DescriptorFlags};
use virtio_core::transport::{Error, Queue, StandardTransport};
@@ -113,12 +114,13 @@ impl<'a> Display<'a> {
.next_multiple_of(syscall::PAGE_SIZE);
let address = unsafe { syscall::physalloc(fb_size) }? as u64;
let mapped = unsafe {
syscall::physmap(
common::physmap(
address as usize,
fb_size,
syscall::PhysmapFlags::PHYSMAP_WRITE,
common::Prot::RW,
common::MemoryType::default(),
)
}?;
}? as usize;
unsafe {
core::ptr::write_bytes(mapped as *mut u8, 255, fb_size);
+1
View File
@@ -29,4 +29,5 @@ smallvec = { version = "1", features = ["serde"] }
thiserror = "1"
toml = "0.5"
common = { path = "../common" }
pcid = { path = "../pcid" }
+3 -3
View File
@@ -19,7 +19,7 @@ use event::{Event, EventQueue};
use redox_log::{RedoxLogger, OutputBuilder};
use syscall::data::Packet;
use syscall::error::EWOULDBLOCK;
use syscall::flag::{EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::flag::EventFlags;
use syscall::scheme::Scheme;
use syscall::io::Io;
@@ -264,8 +264,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
};
let address = unsafe {
syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("xhcid: failed to map address")
common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable)
.expect("xhcid: failed to map address") as usize
};
let (mut irq_file, interrupt_method) = get_int_method(&mut pcid_handle, address);
+3 -1
View File
@@ -2,7 +2,9 @@ use std::collections::BTreeMap;
use log::debug;
use syscall::error::Result;
use syscall::io::{Dma, Io, Mmio};
use syscall::io::{Io, Mmio};
use common::dma::Dma;
use super::Xhci;
use super::ring::Ring;
+3 -1
View File
@@ -1,5 +1,7 @@
use syscall::error::Result;
use syscall::io::{Dma, Io, Mmio};
use syscall::io::{Io, Mmio};
use common::dma::Dma;
use super::Xhci;
use super::ring::Ring;
+5 -3
View File
@@ -9,13 +9,15 @@ use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::{mem, process, slice, sync::atomic, task, thread};
use syscall::error::{Error, Result, EBADF, EBADMSG, ENOENT, EIO};
use syscall::flag::{O_RDONLY, PhysallocFlags};
use syscall::io::Io;
use chashmap::CHashMap;
use common::dma::{Dma, PhysBox};
use crossbeam_channel::{Receiver, Sender};
use log::{debug, error, info, trace, warn};
use serde::Deserialize;
use syscall::error::{Error, Result, EBADF, EBADMSG, ENOENT, EIO};
use syscall::flag::{O_RDONLY, PhysallocFlags};
use syscall::io::{Dma, Io, PhysBox};
use crate::usb;
+2 -1
View File
@@ -1,7 +1,8 @@
use std::mem;
use syscall::error::Result;
use syscall::io::Dma;
use common::dma::Dma;
use super::Xhci;
use super::trb::Trb;
+2 -1
View File
@@ -4,12 +4,13 @@ use std::ops::Deref;
use std::sync::atomic;
use std::{cmp, fmt, io, mem, path, str};
use common::dma::Dma;
use futures::executor::block_on;
use log::{debug, error, info, warn, trace};
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use syscall::io::{Dma, Io};
use syscall::io::Io;
use syscall::scheme::Scheme;
use syscall::{
Error, Result, Stat, EACCES, EBADF, EBADFD, EBADMSG, EEXIST, EINVAL, EIO, EISDIR, ENOENT,