From 64789977a2ffd70a85cc3b1633e53d0c4436a880 Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Sat, 21 Dec 2024 11:50:01 +0000 Subject: [PATCH] Update neotron-common-bios to 0.12 --- Cargo.lock | 418 ++++++++++++++++++++++++---------------------------- Cargo.toml | 2 +- src/main.rs | 123 ++++++---------- 3 files changed, 242 insertions(+), 301 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2beacda..2b3c9ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,29 +1,30 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -45,48 +46,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", "windows-sys", @@ -94,9 +95,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "atty" @@ -104,16 +105,16 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" @@ -122,16 +123,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitflags" -version = "2.3.3" +name = "bumpalo" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "bumpalo" -version = "3.13.0" +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "c_vec" @@ -141,9 +142,12 @@ checksum = "fdd7a427adc0135366d99db65b36dae9237130997e560ed61118041fb72be6e8" [[package]] name = "cc" -version = "1.0.79" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -153,35 +157,33 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] name = "clap" -version = "4.3.12" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.12" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -191,9 +193,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -203,27 +205,27 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -241,41 +243,20 @@ dependencies = [ "termcolor", ] -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fdeflate" -version = "0.3.0" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" dependencies = [ "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -283,14 +264,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -305,9 +286,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -318,12 +299,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - [[package]] name = "humantime" version = "2.1.0" @@ -332,16 +307,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -354,36 +329,32 @@ dependencies = [ ] [[package]] -name = "is-terminal" -version = "0.4.9" +name = "is_terminal_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix", - "windows-sys", -] +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" @@ -395,17 +366,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" - [[package]] name = "log" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" @@ -418,25 +383,25 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ - "adler", + "adler2", "simd-adler32", ] [[package]] name = "neotron-common-bios" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9adad98cd2c761f72321c516359f53b8e0cd56637ee6332e7d8628d8144cad3a" +checksum = "24fdb319a4bdecd68d9917e5cc026a2b50d32572649880febb1f993a0bf9ad00" dependencies = [ "chrono", "neotron-ffi", @@ -463,18 +428,18 @@ checksum = "d37886e73d87732421aaf5da617eead9d69a7daf6b0d059780f76157d9ce5372" [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "pc-keyboard" @@ -489,7 +454,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad75f055157b8a651ade0c7f831f9dc518f1fc4054bfdf16cb47d17b2139cfc3" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags", "chrono", "getrandom", "log", @@ -504,11 +469,11 @@ dependencies = [ [[package]] name = "png" -version = "0.17.9" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ - "bitflags 1.3.2", + "bitflags", "crc32fast", "fdeflate", "flate2", @@ -517,24 +482,27 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -571,9 +539,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -583,9 +551,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -594,22 +562,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" - -[[package]] -name = "rustix" -version = "0.38.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" -dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "sdl2" @@ -617,7 +572,7 @@ version = "0.35.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a" dependencies = [ - "bitflags 1.3.2", + "bitflags", "c_vec", "lazy_static", "libc", @@ -635,23 +590,29 @@ dependencies = [ "version-compare", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simd-adler32" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.25" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -660,55 +621,44 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "version-compare" @@ -718,15 +668,9 @@ checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" [[package]] name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -736,23 +680,23 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -761,9 +705,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -771,9 +715,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -784,9 +728,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "winapi" @@ -806,11 +750,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -820,32 +764,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ "windows-targets", ] [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -854,42 +799,69 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index a684d11..8a6d8c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,5 @@ clap = {version = "4.2", features = ["derive"]} env_logger = "0.9" libloading = "0.7" log = "0.4" -neotron-common-bios = "0.11" +neotron-common-bios = "0.12" pix-engine = "0.7" diff --git a/src/main.rs b/src/main.rs index ba2f7ee..2da3075 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ use std::io::prelude::*; use std::path::PathBuf; +use std::sync::atomic::AtomicPtr; use std::sync::{ atomic::{AtomicU32, AtomicU8, Ordering}, mpsc, Mutex, @@ -64,6 +65,7 @@ enum AppEvent { /// Our video RAM struct Framebuffer { contents: std::cell::UnsafeCell<[u8; N]>, + alt_pointer: AtomicPtr, } /// A Desktop GUI version of a Neotron BIOS @@ -96,7 +98,7 @@ struct Hardware { /// We only have 'normal' sectored emulated disks const BLOCK_SIZE: usize = 512; -/// The VRAM we share in a very hazardous way with the OS. +/// The default VRAM we share in a very hazardous way with the OS. /// /// Big enough for 640x480 @ 256 colour. // static mut FRAMEBUFFER: [u8; 307200] = [0u8; 307200]; @@ -125,7 +127,6 @@ static BIOS_API: common::Api = common::Api { video_set_mode, video_get_mode, video_get_framebuffer, - video_set_framebuffer, video_wait_for_line, memory_get_region, hid_get_event, @@ -720,8 +721,8 @@ fn main() { } let white_on_black = common::video::Attr::new( - common::video::TextForegroundColour::WHITE, - common::video::TextBackgroundColour::BLACK, + common::video::TextForegroundColour::White, + common::video::TextBackgroundColour::Black, false, ); for char_idx in 0..(80 * 60) { @@ -855,9 +856,9 @@ extern "C" fn serial_read( /// Gregorian calendar. It simply stores time as an incrementing number of /// seconds since some epoch, and the number of milliseconds since that second /// began. A day is assumed to be exactly 86,400 seconds long. This is a lot -/// like POSIX time, except we have a different epoch -/// - the Neotron epoch is 2000-01-01T00:00:00Z. It is highly recommend that you -/// store UTC in the BIOS and use the OS to handle time-zones. +/// like POSIX time, except we have a different epoch - the Neotron epoch is +/// 2000-01-01T00:00:00Z. It is highly recommend that you store UTC in the BIOS +/// and use the OS to handle time-zones. /// /// If the BIOS does not have a battery-backed clock, or if that battery has /// failed to keep time, the system starts up assuming it is the epoch. @@ -895,7 +896,7 @@ extern "C" fn time_clock_set(time: common::Time) { extern "C" fn configuration_get(mut os_buffer: common::FfiBuffer) -> common::ApiResult { let file_path = CONFIG_FILE_PATH.lock().unwrap().clone(); let Some(os_buffer) = os_buffer.as_mut_slice() else { - return common::ApiResult::Err(common::Error::DeviceError(0)); + return common::ApiResult::Err(common::Error::DeviceError); }; match file_path.as_ref() { Some(path) => match std::fs::read(path) { @@ -907,7 +908,7 @@ extern "C" fn configuration_get(mut os_buffer: common::FfiBuffer) -> common::Api } Err(_e) => { println!("Failed to get config from {:?}", path); - common::ApiResult::Err(common::Error::DeviceError(0)) + common::ApiResult::Err(common::Error::DeviceError) } }, None => common::ApiResult::Err(common::Error::Unimplemented), @@ -924,7 +925,7 @@ extern "C" fn configuration_set(buffer: common::FfiByteSlice) -> common::ApiResu Ok(_) => common::ApiResult::Ok(()), Err(_e) => { println!("Failed to write config to {:?}", path); - common::ApiResult::Err(common::Error::DeviceError(0)) + common::ApiResult::Err(common::Error::DeviceError) } }, None => common::ApiResult::Err(common::Error::Unimplemented), @@ -943,13 +944,7 @@ extern "C" fn video_is_valid_mode(mode: common::video::Mode) -> bool { /// Switch to a new video mode. /// /// The contents of the screen are undefined after a call to this function. -/// -/// If the BIOS does not have enough reserved RAM (or dedicated VRAM) to -/// support this mode, the change will succeed but a subsequent call to -/// `video_get_framebuffer` will return `null`. You must then supply a -/// pointer to a block of size `Mode::frame_size_bytes()` to -/// `video_set_framebuffer` before any video will appear. -extern "C" fn video_set_mode(mode: common::video::Mode) -> common::ApiResult<()> { +extern "C" fn video_set_mode(mode: common::video::Mode, fb: *mut u32) -> common::ApiResult<()> { info!("video_set_mode({:?})", mode); match mode.timing() { common::video::Timing::T640x480 => { @@ -959,9 +954,7 @@ extern "C" fn video_set_mode(mode: common::video::Mode) -> common::ApiResult<()> // OK } _ => { - return common::ApiResult::Err(common::Error::UnsupportedConfiguration( - mode.as_u8() as u16 - )); + return common::ApiResult::Err(common::Error::UnsupportedConfiguration); } } match mode.format() { @@ -972,15 +965,14 @@ extern "C" fn video_set_mode(mode: common::video::Mode) -> common::ApiResult<()> // OK } _ => { - return common::ApiResult::Err(common::Error::UnsupportedConfiguration( - mode.as_u8() as u16 - )); + return common::ApiResult::Err(common::Error::UnsupportedConfiguration); } } // We know this is a valid video mode because it was set with `video_set_mode`. let mode_value = mode.as_u8(); - VIDEO_MODE.store(mode_value, Ordering::SeqCst); + VIDEO_MODE.store(mode_value, Ordering::Relaxed); + FRAMEBUFFER.alt_pointer.store(fb, Ordering::Relaxed); common::ApiResult::Ok(()) } @@ -991,7 +983,7 @@ extern "C" fn video_set_mode(mode: common::video::Mode) -> common::ApiResult<()> /// serviced without supplying extra RAM. extern "C" fn video_get_mode() -> common::video::Mode { debug!("video_get_mode()"); - let mode_value = VIDEO_MODE.load(Ordering::SeqCst); + let mode_value = VIDEO_MODE.load(Ordering::Relaxed); // We know this is a valid video mode because it was set with `video_set_mode`. unsafe { common::video::Mode::from_u8(mode_value) } } @@ -1002,34 +994,12 @@ extern "C" fn video_get_mode() -> common::video::Mode { /// meaning of the data we write, and the size of the region we are /// allowed to write to, is a function of the current video mode (see /// `video_get_mode`). -/// -/// This function will return `null` if the BIOS isn't able to support the -/// current video mode from its memory reserves. If that happens, you will -/// need to use some OS RAM or Application RAM and provide that as a -/// framebuffer to `video_set_framebuffer`. The BIOS will always be able -/// to provide the 'basic' text buffer experience from reserves, so this -/// function will never return `null` on start-up. -extern "C" fn video_get_framebuffer() -> *mut u8 { - let p = FRAMEBUFFER.get_pointer(); +extern "C" fn video_get_framebuffer() -> *mut u32 { + let p = FRAMEBUFFER.get_pointer() as *mut u32; debug!("video_get_framebuffer() -> {:p}", p); p } -/// Set the framebuffer address. -/// -/// Tell the BIOS where it should start fetching pixel or textual data from -/// (depending on the current video mode). -/// -/// This value is forgotten after a video mode change and must be re-supplied. -/// -/// # Safety -/// -/// The pointer must point to enough video memory to handle the current video -/// mode, and any future video mode you set. -unsafe extern "C" fn video_set_framebuffer(_buffer: *const u8) -> common::ApiResult<()> { - Err(common::Error::Unimplemented).into() -} - /// Find out whether the given video mode needs more VRAM than we currently have. /// /// The answer is no for any currently supported video mode (which is just the four text modes right now). @@ -1072,7 +1042,7 @@ extern "C" fn memory_get_region(region: u8) -> common::FfiOption common::FfiOption::None, @@ -1269,7 +1239,7 @@ extern "C" fn video_get_palette(index: u8) -> common::FfiOption common::FfiOption::Some(rgb), None => common::FfiOption::None, @@ -1279,7 +1249,7 @@ extern "C" fn video_get_palette(index: u8) -> common::FfiOption common::FfiOption common::FfiOption::Some(common::block_dev::DeviceInfo { name: common::FfiString::new("File0"), - device_type: common::block_dev::DeviceType::HardDiskDrive, + device_type: common::block_dev::DeviceType::HardDiskDrive.into(), block_size: BLOCK_SIZE as u32, num_blocks: file.metadata().unwrap().len() / (BLOCK_SIZE as u64), ejectable: false, @@ -1460,11 +1430,11 @@ extern "C" fn block_write( let buffer_slice = &buffer.as_slice()[0..usize::from(num_blocks) * BLOCK_SIZE]; if let Err(e) = file.write_all(buffer_slice) { log::warn!("Failed to write to disk image: {:?}", e); - return common::ApiResult::Err(common::Error::DeviceError(0)); + return common::ApiResult::Err(common::Error::DeviceError); } common::ApiResult::Ok(()) } - None => common::ApiResult::Err(common::Error::DeviceError(0)), + None => common::ApiResult::Err(common::Error::DeviceError), } } else { common::ApiResult::Err(common::Error::InvalidDevice) @@ -1496,12 +1466,12 @@ extern "C" fn block_read( let buffer_slice = &mut buffer_slice[0..usize::from(num_blocks) * BLOCK_SIZE]; if let Err(e) = file.read_exact(buffer_slice) { log::warn!("Failed to read from disk image: {:?}", e); - return common::ApiResult::Err(common::Error::DeviceError(0)); + return common::ApiResult::Err(common::Error::DeviceError); } } common::ApiResult::Ok(()) } - None => common::ApiResult::Err(common::Error::DeviceError(0)), + None => common::ApiResult::Err(common::Error::DeviceError), } } else { common::ApiResult::Err(common::Error::InvalidDevice) @@ -1533,15 +1503,15 @@ extern "C" fn block_verify( let mut read_buffer = vec![0u8; buffer_slice.len()]; if let Err(e) = file.read_exact(&mut read_buffer) { log::warn!("Failed to write to disk image: {:?}", e); - return common::ApiResult::Err(common::Error::DeviceError(0)); + return common::ApiResult::Err(common::Error::DeviceError); } if read_buffer.as_slice() == buffer_slice { common::ApiResult::Ok(()) } else { - common::ApiResult::Err(common::Error::DeviceError(1)) + common::ApiResult::Err(common::Error::DeviceError) } } - None => common::ApiResult::Err(common::Error::DeviceError(0)), + None => common::ApiResult::Err(common::Error::DeviceError), } } else { common::ApiResult::Err(common::Error::InvalidDevice) @@ -1552,7 +1522,7 @@ extern "C" fn power_idle() { std::thread::sleep(std::time::Duration::from_millis(1)); } -extern "C" fn power_control(mode: common::PowerMode) -> ! { +extern "C" fn power_control(mode: common::FfiPowerMode) -> ! { println!("Got power mode {:?}, but quitting...", mode); std::process::exit(0); } @@ -1562,7 +1532,7 @@ extern "C" fn compare_and_swap_bool( old_value: bool, new_value: bool, ) -> bool { - item.compare_exchange(old_value, new_value, Ordering::SeqCst, Ordering::SeqCst) + item.compare_exchange(old_value, new_value, Ordering::Relaxed, Ordering::Relaxed) .is_ok() } @@ -1667,7 +1637,7 @@ impl PixEngine for MyApp { /// /// We convert the contents of `FRAMEBUFFER` into pixels on the canvas. fn on_update(&mut self, s: &mut PixState) -> PixResult<()> { - let mode_value = VIDEO_MODE.load(Ordering::SeqCst); + let mode_value = VIDEO_MODE.load(Ordering::Relaxed); let new_mode = unsafe { common::video::Mode::from_u8(mode_value) }; if new_mode != self.mode { self.mode = new_mode; @@ -1700,10 +1670,10 @@ impl PixEngine for MyApp { let x = col * 8; let glyph = FRAMEBUFFER.get_at(byte_offset); let attr = common::video::Attr(FRAMEBUFFER.get_at(byte_offset + 1)); - let fg_idx = attr.fg().as_u8(); - let bg_idx = attr.bg().as_u8(); + let fg_idx = attr.fg().make_ffi_safe().0; + let bg_idx = attr.bg().make_ffi_safe().0; let bg = - RGBColour::from_packed(PALETTE[usize::from(bg_idx)].load(Ordering::SeqCst)); + RGBColour::from_packed(PALETTE[usize::from(bg_idx)].load(Ordering::Relaxed)); let glyph_box = rect!(i32::from(x), i32::from(y), 8i32, font_height as i32,); s.fill(rgb!(bg.red(), bg.green(), bg.blue())); s.rect(glyph_box)?; @@ -1723,6 +1693,7 @@ impl Framebuffer { const fn new() -> Framebuffer { Framebuffer { contents: std::cell::UnsafeCell::new([0u8; N]), + alt_pointer: AtomicPtr::new(core::ptr::null_mut()), } } @@ -1732,11 +1703,8 @@ impl Framebuffer { /// /// Uses volatile writes. fn write_at(&self, offset: usize, value: u8) { - if offset > std::mem::size_of_val(&self.contents) { - panic!("Out of bounds framebuffer write"); - } unsafe { - let array_ptr = self.contents.get() as *mut u8; + let array_ptr = self.get_pointer() as *mut u8; let byte_ptr = array_ptr.add(offset); byte_ptr.write_volatile(value); } @@ -1748,19 +1716,20 @@ impl Framebuffer { /// /// Uses volatile reads. fn get_at(&self, offset: usize) -> u8 { - if offset > std::mem::size_of_val(&self.contents) { - panic!("Out of bounds framebuffer read"); - } unsafe { - let array_ptr = self.contents.get() as *const u8; + let array_ptr = self.get_pointer() as *const u8; let byte_ptr = array_ptr.add(offset); byte_ptr.read_volatile() } } /// Get a pointer to the framebuffer you can give to the OS. - fn get_pointer(&self) -> *mut u8 { - self.contents.get() as *mut u8 + fn get_pointer(&self) -> *mut u32 { + let mut p = self.alt_pointer.load(Ordering::Relaxed); + if p.is_null() { + p = self.contents.get() as *mut u32; + } + p } }