├── .appveyor.yml ├── .gitignore ├── .travis.yml ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── intermezzos.json ├── src ├── lib.rs ├── main.rs └── panic.rs └── vga ├── .gitignore ├── Cargo.toml ├── README.md ├── src ├── character.rs └── lib.rs └── tests └── vga.rs /.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration template for Rust using rustup for Rust installation 2 | # https://github.com/starkat99/appveyor-rust 3 | 4 | ## Operating System (VM environment) ## 5 | 6 | # Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. 7 | os: Visual Studio 2015 8 | 9 | ## Build Matrix ## 10 | environment: 11 | matrix: 12 | 13 | ### MSVC Toolchains ### 14 | # Nightly 64-bit MSVC 15 | - channel: nightly 16 | target: x86_64-pc-windows-msvc 17 | MSYS_BITS: 64 18 | # Nightly 32-bit MSVC 19 | - channel: nightly 20 | target: i686-pc-windows-msvc 21 | MSYS_BITS: 32 22 | 23 | ### GNU Toolchains ### 24 | # Nightly 64-bit GNU 25 | - channel: nightly 26 | target: x86_64-pc-windows-gnu 27 | MSYS_BITS: 64 28 | # Nightly 32-bit GNU 29 | - channel: nightly 30 | target: i686-pc-windows-gnu 31 | MSYS_BITS: 32 32 | 33 | cache: 34 | - '%USERPROFILE%\.cargo\bin' 35 | - '%USERPROFILE%\.cargo\config' 36 | - '%USERPROFILE%\.cargo\env' 37 | - '%USERPROFILE%\.cargo\.crates.toml' 38 | - target 39 | 40 | ## Install Script ## 41 | 42 | # This is the most important part of the Appveyor configuration. This installs the version of Rust 43 | # specified by the 'channel' and 'target' environment variables from the build matrix. This uses 44 | # rustup to install Rust. 45 | # 46 | # For simple configurations, instead of using the build matrix, you can simply set the 47 | # default-toolchain and default-host manually here. 48 | install: 49 | - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe 50 | - rustup-init -yv --default-toolchain %channel% --default-host %target% 51 | - set PATH=%PATH%;%USERPROFILE%\.cargo\bin 52 | - rustc -vV 53 | - cargo -vV 54 | 55 | ## Build Script ## 56 | 57 | # 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents 58 | # the "directory does not contain a project or solution file" error. 59 | build: false 60 | 61 | before_test: 62 | - set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% 63 | # Fix undefined references to __acrt_iob_func() 64 | - sed -rie "s/#define std([[:alpha:]]+)[[:space:]]+\(__acrt_iob_func\(([[:digit:]]+)\)\)/#define std\1 (\&__iob_func()[\2])/" "C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h" 65 | - sed -rie "s/#define std([[:alpha:]]+)[[:space:]]+\(__acrt_iob_func\(([[:digit:]]+)\)\)/#define std\1 (\&__iob_func()[\2])/" "C:\msys64\mingw32\i686-w64-mingw32\include\stdio.h" 66 | - rustup component add rust-src 67 | - set RUST_BACKTRACE=1 68 | - if not exist %USERPROFILE%\.cargo\bin\cargo-install-update.exe cargo install cargo-update 69 | - if not exist %USERPROFILE%\.cargo\bin\cargo-xbuild.exe cargo install cargo-xbuild 70 | - if not exist %USERPROFILE%\.cargo\bin\bootimage.exe cargo install bootimage 71 | - cargo install-update -a 72 | 73 | # Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs 74 | # directly or perform other testing commands. Rust will automatically be placed in the PATH 75 | # environment variable. 76 | test_script: 77 | - cargo test 78 | - bootimage build --target intermezzos.json 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | bootimage.bin 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | 3 | rust: 4 | - nightly 5 | 6 | os: 7 | - linux 8 | - osx 9 | 10 | before_script: 11 | - rustup component add rustfmt 12 | - rustup component add rust-src 13 | - rustup component add llvm-tools-preview 14 | - (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) 15 | - (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild) 16 | - (test -x $HOME/.cargo/bin/bootimage || cargo install bootimage) 17 | - cargo install-update -a 18 | 19 | script: 20 | - cargo test 21 | - bootimage build 22 | - cargo fmt -- --check 23 | 24 | cache: cargo 25 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "array-init" 5 | version = "0.0.4" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | dependencies = [ 8 | "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "bit_field" 13 | version = "0.9.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | 16 | [[package]] 17 | name = "bitflags" 18 | version = "1.0.4" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | 21 | [[package]] 22 | name = "bootloader" 23 | version = "0.6.4" 24 | source = "registry+https://github.com/rust-lang/crates.io-index" 25 | dependencies = [ 26 | "fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 27 | "llvm-tools 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 28 | "usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 29 | "x86_64 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", 30 | "xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", 31 | ] 32 | 33 | [[package]] 34 | name = "cast" 35 | version = "0.2.2" 36 | source = "registry+https://github.com/rust-lang/crates.io-index" 37 | 38 | [[package]] 39 | name = "fixedvec" 40 | version = "0.2.3" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | dependencies = [ 43 | "skeptic 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", 44 | ] 45 | 46 | [[package]] 47 | name = "fuchsia-zircon" 48 | version = "0.3.3" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | dependencies = [ 51 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 52 | "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 53 | ] 54 | 55 | [[package]] 56 | name = "fuchsia-zircon-sys" 57 | version = "0.3.3" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | 60 | [[package]] 61 | name = "getopts" 62 | version = "0.2.18" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | dependencies = [ 65 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 66 | ] 67 | 68 | [[package]] 69 | name = "intermezzos" 70 | version = "0.1.0" 71 | dependencies = [ 72 | "bootloader 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "vga 0.1.0", 74 | ] 75 | 76 | [[package]] 77 | name = "libc" 78 | version = "0.2.45" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | 81 | [[package]] 82 | name = "llvm-tools" 83 | version = "0.1.1" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | 86 | [[package]] 87 | name = "nodrop" 88 | version = "0.1.13" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | 91 | [[package]] 92 | name = "pulldown-cmark" 93 | version = "0.0.3" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | dependencies = [ 96 | "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", 97 | ] 98 | 99 | [[package]] 100 | name = "rand" 101 | version = "0.4.3" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | dependencies = [ 104 | "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 105 | "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 107 | ] 108 | 109 | [[package]] 110 | name = "remove_dir_all" 111 | version = "0.5.1" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | dependencies = [ 114 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 115 | ] 116 | 117 | [[package]] 118 | name = "skeptic" 119 | version = "0.5.0" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | dependencies = [ 122 | "pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 123 | "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", 124 | ] 125 | 126 | [[package]] 127 | name = "tempdir" 128 | version = "0.3.7" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | dependencies = [ 131 | "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 132 | "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 133 | ] 134 | 135 | [[package]] 136 | name = "unicode-width" 137 | version = "0.1.5" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | 140 | [[package]] 141 | name = "usize_conversions" 142 | version = "0.2.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | 145 | [[package]] 146 | name = "ux" 147 | version = "0.1.3" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | 150 | [[package]] 151 | name = "vga" 152 | version = "0.1.0" 153 | 154 | [[package]] 155 | name = "winapi" 156 | version = "0.3.6" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | dependencies = [ 159 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 160 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 161 | ] 162 | 163 | [[package]] 164 | name = "winapi-i686-pc-windows-gnu" 165 | version = "0.4.0" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | 168 | [[package]] 169 | name = "winapi-x86_64-pc-windows-gnu" 170 | version = "0.4.0" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | 173 | [[package]] 174 | name = "x86_64" 175 | version = "0.7.4" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | dependencies = [ 178 | "array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 179 | "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 180 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 182 | "ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 183 | ] 184 | 185 | [[package]] 186 | name = "xmas-elf" 187 | version = "0.6.2" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | dependencies = [ 190 | "zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 191 | ] 192 | 193 | [[package]] 194 | name = "zero" 195 | version = "0.1.2" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | 198 | [metadata] 199 | "checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" 200 | "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" 201 | "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" 202 | "checksum bootloader 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b15e5b7b9d9a8e427cf4270894f51ce288632a3a1a2cc6f8fda669d5446f98bd" 203 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 204 | "checksum fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6c16d316ccdac21a4dd648e314e76facbbaf316e83ca137d0857a9c07419d0" 205 | "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 206 | "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 207 | "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" 208 | "checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" 209 | "checksum llvm-tools 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf" 210 | "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" 211 | "checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07" 212 | "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" 213 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" 214 | "checksum skeptic 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "061203a849117b0f7090baf8157aa91dac30545208fbb85166ac58b4ca33d89c" 215 | "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" 216 | "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" 217 | "checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5" 218 | "checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f" 219 | "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" 220 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 221 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 222 | "checksum x86_64 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1ad37c1665071808d64e65f7cdae32afcdc90fd7ae7fa402bbda36b824f1add6" 223 | "checksum xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22678df5df766e8d1e5d609da69f0c3132d794edf6ab5e75e7abcd2270d4cf58" 224 | "checksum zero 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5" 225 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "intermezzos" 3 | version = "0.1.0" 4 | authors = ["steveklabnik "] 5 | 6 | [package.metadata.bootimage] 7 | default-target = "intermezzos.json" 8 | 9 | [workspace] 10 | 11 | [dependencies] 12 | bootloader = "0.6.4" 13 | 14 | [dependencies.vga] 15 | path = "vga" 16 | 17 | [[bin]] 18 | name = "intermezzos" 19 | test = false 20 | 21 | [profile.dev] 22 | panic = "abort" 23 | 24 | [profile.release] 25 | panic = "abort" 26 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 intermezzOS Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # intermezzOS: kernel 2 | 3 | [![Build Status](https://travis-ci.org/intermezzOS/kernel.svg?branch=master)](https://travis-ci.org/intermezzOS/kernel) [![Build status](https://ci.appveyor.com/api/projects/status/uoy6584lg6b9wog6?svg=true)](https://ci.appveyor.com/project/steveklabnik/kernel) 4 | 5 | intermezzOS is a hobby operating system. This repository is for its kernel. 6 | See [the website](http://intermezzos.github.io/) for more. 7 | 8 | ## License 9 | 10 | This project is dual licensed under Apache2/MIT. See the two `LICENSE-*` files 11 | for details. 12 | 13 | ## Code of conduct 14 | 15 | The intermezzOS project has a [Code of 16 | Conduct](http://intermezzos.github.io/code-of-conduct.html), please observe it. 17 | -------------------------------------------------------------------------------- /intermezzos.json: -------------------------------------------------------------------------------- 1 | { 2 | "llvm-target": "x86_64-unknown-none", 3 | "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", 4 | "arch": "x86_64", 5 | "target-endian": "little", 6 | "target-pointer-width": "64", 7 | "target-c-int-width": "32", 8 | "os": "none", 9 | "linker": "rust-lld", 10 | "linker-flavor": "ld.lld", 11 | "executables": true, 12 | "features": "-mmx,-sse,+soft-float", 13 | "disable-redzone": true, 14 | "panic-strategy": "abort" 15 | } 16 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | #[macro_export] 4 | macro_rules! kprintln { 5 | ($ctx:ident, $fmt:expr) => (kprint!($ctx, concat!($fmt, "\n"))); 6 | ($ctx:ident, $fmt:expr, $($arg:tt)*) => (kprint!($ctx, concat!($fmt, "\n"), $($arg)*)); 7 | } 8 | 9 | #[macro_export] 10 | macro_rules! kprint { 11 | ($ctx:ident, $($arg:tt)*) => ({ 12 | use core::fmt::Write; 13 | $ctx.write_fmt(format_args!($($arg)*)).unwrap(); 14 | $ctx.flush(); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![feature(core_intrinsics)] 2 | #![no_std] 3 | #![no_main] 4 | 5 | extern crate vga; 6 | #[macro_use] 7 | extern crate intermezzos; 8 | extern crate bootloader; 9 | 10 | #[cfg(not(test))] 11 | pub mod panic; 12 | 13 | use vga::Vga; 14 | 15 | #[no_mangle] 16 | pub fn _start() -> ! { 17 | let slice = unsafe { core::slice::from_raw_parts_mut(0xb8000 as *mut u8, 4000) }; 18 | 19 | let mut vga = Vga::new(slice); 20 | 21 | kprintln!(vga, "hello world"); 22 | 23 | loop {} 24 | } 25 | -------------------------------------------------------------------------------- /src/panic.rs: -------------------------------------------------------------------------------- 1 | use core::intrinsics; 2 | use core::panic::PanicInfo; 3 | 4 | #[panic_handler] 5 | #[no_mangle] 6 | pub fn panic(_info: &PanicInfo) -> ! { 7 | unsafe { intrinsics::abort() } 8 | } 9 | -------------------------------------------------------------------------------- /vga/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /vga/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vga" 3 | version = "0.1.0" 4 | authors = ["The intermezzOS team"] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /vga/README.md: -------------------------------------------------------------------------------- 1 | # test-driven vga driver 2 | 3 | this repo is proof of concept for writing a vga driver tdd-style. 4 | -------------------------------------------------------------------------------- /vga/src/character.rs: -------------------------------------------------------------------------------- 1 | #[derive(Copy, Clone, PartialEq, Debug)] 2 | pub struct Character { 3 | character: u8, 4 | attribute: u8, 5 | } 6 | 7 | #[derive(Copy, Clone, PartialEq, Debug)] 8 | pub enum Color { 9 | Black = 0x0, 10 | Blue = 0x1, 11 | Green = 0x2, 12 | Cyan = 0x3, 13 | Red = 0x4, 14 | Magenta = 0x5, 15 | Brown = 0x6, 16 | Gray = 0x7, 17 | DarkGray = 0x8, 18 | BrightBlue = 0x9, 19 | BrightGreen = 0xA, 20 | BrightCyan = 0xB, 21 | BrightRed = 0xC, 22 | BrightMagenta = 0xD, 23 | Yellow = 0xE, 24 | White = 0xF, 25 | } 26 | 27 | impl Character { 28 | pub fn new(character: u8, foreground: Color, background: Color) -> Character { 29 | let attribute = ((background as u8) << 4) + (foreground as u8); 30 | 31 | Character { 32 | character, 33 | attribute, 34 | } 35 | } 36 | 37 | pub fn as_bytes(&self) -> (u8, u8) { 38 | (self.character, self.attribute) 39 | } 40 | } 41 | 42 | #[cfg(test)] 43 | mod tests { 44 | use super::*; 45 | 46 | #[test] 47 | fn creation() { 48 | let character = Character::new(b'a', Color::Blue, Color::BrightMagenta); 49 | 50 | assert_eq!(character.character, b'a'); 51 | assert_eq!(character.attribute, 0xD1); 52 | 53 | let character = Character::new(b'b', Color::Yellow, Color::Red); 54 | 55 | assert_eq!(character.character, b'b'); 56 | assert_eq!(character.attribute, 0x4E); 57 | 58 | let character = Character::new(b'c', Color::DarkGray, Color::White); 59 | 60 | assert_eq!(character.character, b'c'); 61 | assert_eq!(character.attribute, 0xF8); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vga/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![feature(nll)] 3 | 4 | use core::fmt; 5 | use core::fmt::Write; 6 | use core::ptr; 7 | 8 | mod character; 9 | 10 | use character::Character; 11 | pub use character::Color; 12 | 13 | const ROWS: usize = 25; 14 | const COLS: usize = 80; 15 | 16 | pub struct Vga> { 17 | slice: T, 18 | buffer: [Character; ROWS * COLS], 19 | position: usize, 20 | foreground_color: Color, 21 | background_color: Color, 22 | } 23 | 24 | impl> Vga { 25 | pub fn new(mut slice: T) -> Vga { 26 | // we must have enough bytes of backing storage to make this work. 27 | assert_eq!(slice.as_mut().len(), ROWS * COLS * 2); 28 | 29 | let foreground_color = Color::Green; 30 | let background_color = Color::Black; 31 | 32 | let buffer = [Character::new(b' ', foreground_color, background_color); ROWS * COLS]; 33 | 34 | Vga { 35 | slice, 36 | buffer, 37 | position: 0, 38 | foreground_color, 39 | background_color, 40 | } 41 | } 42 | 43 | pub fn set_foreground_color(&mut self, color: Color) { 44 | self.foreground_color = color; 45 | } 46 | 47 | pub fn set_background_color(&mut self, color: Color) { 48 | self.background_color = color; 49 | } 50 | 51 | pub fn flush(&mut self) { 52 | // we need to use `write_volatile` here so that the writes aren't optimized out 53 | unsafe { 54 | let p = self.slice.as_mut(); 55 | 56 | for (chunk, character) in p.chunks_mut(2).zip(self.buffer.iter()) { 57 | let (character, attribute) = character.as_bytes(); 58 | 59 | let p = &mut chunk[0] as *mut u8; 60 | ptr::write_volatile(p, character); 61 | 62 | let p = &mut chunk[1] as *mut u8; 63 | ptr::write_volatile(p, attribute); 64 | } 65 | } 66 | } 67 | 68 | fn write_byte(&mut self, byte: u8) { 69 | let i = self.position; 70 | 71 | if byte == '\n' as u8 { 72 | let current_line = self.position / COLS; 73 | self.position = (current_line + 1) * COLS; 74 | } else { 75 | self.buffer[i] = Character::new(byte, self.foreground_color, self.background_color); 76 | 77 | self.position += 1; 78 | } 79 | 80 | if self.position >= self.buffer.len() { 81 | self.scroll(); 82 | } 83 | } 84 | 85 | fn scroll(&mut self) { 86 | for row in 1..ROWS { 87 | for cb in 0..COLS { 88 | let prev_position = ((row - 1) * COLS) + cb; 89 | let current_position = (row * COLS) + cb; 90 | self.buffer[prev_position] = self.buffer[current_position]; 91 | } 92 | } 93 | 94 | for cb in 0..COLS { 95 | self.buffer[((ROWS - 1) * COLS) + cb] = 96 | Character::new(b' ', self.foreground_color, self.background_color); 97 | } 98 | 99 | self.position = (ROWS - 1) * COLS; 100 | } 101 | } 102 | 103 | impl> Write for Vga { 104 | fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { 105 | for b in s.bytes() { 106 | self.write_byte(b); 107 | } 108 | 109 | Ok(()) 110 | } 111 | } 112 | 113 | #[cfg(test)] 114 | mod tests { 115 | use core::fmt::Write; 116 | use Vga; 117 | 118 | use COLS; 119 | use ROWS; 120 | 121 | #[test] 122 | fn write_a_letter() { 123 | let mut mock_memory = [0u8; ROWS * COLS * 2]; 124 | let mut vga = Vga::new(&mut mock_memory[..]); 125 | 126 | vga.write_str("a").unwrap(); 127 | vga.flush(); 128 | 129 | assert_eq!(mock_memory[0], b'a'); 130 | assert_eq!(mock_memory[1], 0x02); 131 | } 132 | 133 | #[test] 134 | fn write_a_word() { 135 | let mut mock_memory = [0u8; ROWS * COLS * 2]; 136 | let mut vga = Vga::new(&mut mock_memory[..]); 137 | 138 | let word = "word"; 139 | vga.write_str(word).unwrap(); 140 | vga.flush(); 141 | 142 | assert_eq!(mock_memory[0], b'w'); 143 | assert_eq!(mock_memory[1], 0x02); 144 | assert_eq!(mock_memory[2], b'o'); 145 | assert_eq!(mock_memory[3], 0x02); 146 | assert_eq!(mock_memory[4], b'r'); 147 | assert_eq!(mock_memory[5], 0x02); 148 | assert_eq!(mock_memory[6], b'd'); 149 | assert_eq!(mock_memory[7], 0x02); 150 | } 151 | 152 | #[test] 153 | fn write_multiple_words() { 154 | let mut mock_memory = [0u8; ROWS * COLS * 2]; 155 | let mut vga = Vga::new(&mut mock_memory[..]); 156 | 157 | vga.write_str("hello ").unwrap(); 158 | vga.write_str("world").unwrap(); 159 | vga.flush(); 160 | 161 | assert_eq!(mock_memory[0], b'h'); 162 | assert_eq!(mock_memory[1], 0x02); 163 | assert_eq!(mock_memory[2], b'e'); 164 | assert_eq!(mock_memory[3], 0x02); 165 | assert_eq!(mock_memory[4], b'l'); 166 | assert_eq!(mock_memory[5], 0x02); 167 | assert_eq!(mock_memory[6], b'l'); 168 | assert_eq!(mock_memory[7], 0x02); 169 | assert_eq!(mock_memory[8], b'o'); 170 | assert_eq!(mock_memory[9], 0x02); 171 | assert_eq!(mock_memory[10], b' '); 172 | assert_eq!(mock_memory[11], 0x02); 173 | assert_eq!(mock_memory[12], b'w'); 174 | assert_eq!(mock_memory[13], 0x02); 175 | assert_eq!(mock_memory[14], b'o'); 176 | assert_eq!(mock_memory[15], 0x02); 177 | assert_eq!(mock_memory[16], b'r'); 178 | assert_eq!(mock_memory[17], 0x02); 179 | assert_eq!(mock_memory[18], b'l'); 180 | assert_eq!(mock_memory[19], 0x02); 181 | assert_eq!(mock_memory[20], b'd'); 182 | assert_eq!(mock_memory[21], 0x02); 183 | } 184 | 185 | #[test] 186 | fn write_newline() { 187 | let mut mock_memory = [0u8; ROWS * COLS * 2]; 188 | let mut vga = Vga::new(&mut mock_memory[..]); 189 | 190 | vga.write_str("hello\nworld\n!").unwrap(); 191 | vga.flush(); 192 | 193 | assert_eq!(mock_memory[0], b'h'); 194 | assert_eq!(mock_memory[1], 0x02); 195 | assert_eq!(mock_memory[2], b'e'); 196 | assert_eq!(mock_memory[3], 0x02); 197 | assert_eq!(mock_memory[4], b'l'); 198 | assert_eq!(mock_memory[5], 0x02); 199 | assert_eq!(mock_memory[6], b'l'); 200 | assert_eq!(mock_memory[7], 0x02); 201 | assert_eq!(mock_memory[8], b'o'); 202 | assert_eq!(mock_memory[9], 0x02); 203 | assert_eq!(mock_memory[160], b'w'); 204 | assert_eq!(mock_memory[161], 0x02); 205 | assert_eq!(mock_memory[162], b'o'); 206 | assert_eq!(mock_memory[163], 0x02); 207 | assert_eq!(mock_memory[164], b'r'); 208 | assert_eq!(mock_memory[165], 0x02); 209 | assert_eq!(mock_memory[166], b'l'); 210 | assert_eq!(mock_memory[167], 0x02); 211 | assert_eq!(mock_memory[168], b'd'); 212 | assert_eq!(mock_memory[169], 0x02); 213 | assert_eq!(mock_memory[320], b'!'); 214 | assert_eq!(mock_memory[321], 0x02); 215 | } 216 | 217 | #[test] 218 | fn write_scroll() { 219 | let mut mock_memory = [0u8; ROWS * COLS * 2]; 220 | let mut vga = Vga::new(&mut mock_memory[..]); 221 | 222 | for b in "abcdefghijklmnopqrstuvwxyz".bytes() { 223 | vga.write_byte(b); 224 | vga.write_byte('\n' as u8); 225 | } 226 | 227 | vga.flush(); 228 | 229 | assert_eq!(mock_memory[0], b'c'); 230 | 231 | for cb in 0..COLS { 232 | assert_eq!(mock_memory[(ROWS - 1) * COLS * 2 + (cb * 2)], b' '); 233 | } 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /vga/tests/vga.rs: -------------------------------------------------------------------------------- 1 | extern crate core; 2 | extern crate vga; 3 | 4 | use core::fmt::Write; 5 | use vga::Vga; 6 | 7 | #[test] 8 | fn create() { 9 | let mut mock_memory = vec![0u8; 25 * 80 * 2]; 10 | 11 | Vga::new(&mut mock_memory); 12 | } 13 | 14 | fn check_write(_: T) {} 15 | 16 | #[test] 17 | fn write() { 18 | let mut mock_memory = vec![0u8; 25 * 80 * 2]; 19 | let vga = Vga::new(&mut mock_memory); 20 | check_write(vga); 21 | } 22 | 23 | #[test] 24 | fn flush() { 25 | let mut mock_memory = vec![0u8; 25 * 80 * 2]; 26 | 27 | { 28 | let mut vga = Vga::new(&mut mock_memory); 29 | 30 | vga.write_str("hello").unwrap(); 31 | 32 | vga.flush(); 33 | } 34 | 35 | assert_eq!(mock_memory[0], 'h' as u8); 36 | assert_eq!(mock_memory[1], 0x02); 37 | assert_eq!(mock_memory[2], 'e' as u8); 38 | assert_eq!(mock_memory[3], 0x02); 39 | assert_eq!(mock_memory[4], 'l' as u8); 40 | assert_eq!(mock_memory[5], 0x02); 41 | assert_eq!(mock_memory[6], 'l' as u8); 42 | assert_eq!(mock_memory[7], 0x02); 43 | assert_eq!(mock_memory[8], 'o' as u8); 44 | assert_eq!(mock_memory[9], 0x02); 45 | } 46 | --------------------------------------------------------------------------------