Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
neri committed Nov 13, 2023
1 parent 602c985 commit af98728
Show file tree
Hide file tree
Showing 37 changed files with 1,262 additions and 1,440 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: love default all clean install iso run runs test apps doc kernel boot refresh
.SUFFIXED: .wasm
.SUFFIXES: .wasm

MNT = ./mnt/
MISC = ./misc/
Expand Down Expand Up @@ -39,6 +39,10 @@ default: $(TARGETS)
all: $(ALL_TARGETS)

clean:
(cd system; cargo clean)
(cd apps; cargo clean)
(cd boot; cargo clean)
(cd tools; cargo clean)
-rm -rf system/target apps/target boot/target tools/target

refresh: clean
Expand All @@ -57,7 +61,6 @@ run:
$(QEMU_X64) -machine q35 -cpu SandyBridge -smp 4,cores=2,threads=2 \
-bios $(OVMF_X64) \
-rtc base=localtime,clock=host \
-vga virtio \
-device virtio-net-pci \
-device nec-usb-xhci,id=xhci \
-device intel-hda -device hda-duplex \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MEG-OS

***Note: It is currently not possible to build with the latest nightly version.***
***NOTE: IT IS CURRENTLY NOT POSSIBLE TO BUILD WITH THE LATEST NIGHTLY VERSION.***

![GitHub](https://img.shields.io/github/license/neri/maystorm) ![GitHub top language](https://img.shields.io/github/languages/top/neri/maystorm)

Expand Down
6 changes: 3 additions & 3 deletions apps/life/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_main]
#![no_std]

use megstd::{drawing::OneBitColor, sys::syscall::*, window::*};
use megstd::{drawing::Monochrome, sys::syscall::*, window::*};

const BG_COLOR: WindowColor = WindowColor::BLACK;
const FG_COLOR: WindowColor = WindowColor::YELLOW;
Expand Down Expand Up @@ -77,13 +77,13 @@ fn _start() {

let next_life = if life.into_bool() {
if count <= 1 || count >= 4 {
OneBitColor::Zero
Monochrome::Zero
} else {
life
}
} else {
if count == 3 {
OneBitColor::One
Monochrome::One
} else {
life
}
Expand Down
Binary file added assets/initrd/wall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/initrd/wall.png
Binary file not shown.
26 changes: 13 additions & 13 deletions boot/boot-efi/src/page/amd64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,19 @@ impl PageManager {
shared.pml2k = PageTableEntry::new(pml2kp, common_attributes);
pml3k[kernel_base.index_of(3)] = shared.pml2k;

// vram (temp)
let vram_base = info.vram_base;
let vram_size = Self::pages(
info.vram_stride as u64 * info.screen_height as u64 * 4,
PageTableEntry::LARGE_PAGE_SIZE,
) as u64;
let offset = vram_base / PageTableEntry::LARGE_PAGE_SIZE;
for i in 0..vram_size {
pml2[(offset + i) as usize] = PageTableEntry::new(
vram_base + i * PageTableEntry::LARGE_PAGE_SIZE,
common_attributes | PageAttributes::LARGE,
);
}
// // vram (temp)
// let vram_base = info.vram_base;
// let vram_size = Self::pages(
// info.vram_stride as u64 * info.screen_height as u64 * 4,
// PageTableEntry::LARGE_PAGE_SIZE,
// ) as u64;
// let offset = vram_base / PageTableEntry::LARGE_PAGE_SIZE;
// for i in 0..vram_size {
// pml2[(offset + i) as usize] = PageTableEntry::new(
// vram_base + i * PageTableEntry::LARGE_PAGE_SIZE,
// common_attributes | PageAttributes::LARGE,
// );
// }
}

#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion boot/lib-efi/src/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Console {
shared.cols = (width - Self::PADDING_X * 2) / FONT_MEGH0816_WIDTH;
shared.rows = (height - Self::PADDING_Y * 2) / FONT_MEGH0816_HEIGHT;

// shared.fill_rect(0, 0, width, height, 0x000000);
shared.fill_rect(0, 0, width, height, 0x000000);
}

pub fn put_char(&mut self, c: char) {
Expand Down
81 changes: 51 additions & 30 deletions lib/meggl/src/bitmap.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use alloc::{borrow::ToOwned, boxed::Box, vec::Vec};
use core::{
borrow::Borrow,
borrow::{Borrow, BorrowMut},
cell::UnsafeCell,
convert::TryFrom,
intrinsics::copy_nonoverlapping,
Expand All @@ -15,7 +15,7 @@ pub trait Blt<T: Drawable>: Drawable {
fn blt(&mut self, src: &T, origin: Point, rect: Rect);
}

pub trait BasicDrawing: SetPixel {
pub trait DrawRect: SetPixel {
fn fill_rect(&mut self, rect: Rect, color: Self::ColorType);

fn draw_hline(&mut self, origin: Point, width: isize, color: Self::ColorType);
Expand Down Expand Up @@ -297,7 +297,7 @@ pub trait DrawGlyph: SetPixel {
}
}

pub trait BltConvert<T: ColorTrait>: MutableRasterImage {
pub trait BltConvert<T: PixelColor>: MutableRasterImage {
#[inline]
fn blt_convert<U, F>(&mut self, src: &U, origin: Point, rect: Rect, mut f: F)
where
Expand Down Expand Up @@ -460,7 +460,7 @@ macro_rules! define_bitmap {
stride: Option<NonZeroUsize>,
) -> Self
where
<Self as Drawable>::ColorType: ~const ColorTrait,
<Self as Drawable>::ColorType: ~const PixelColor,
{
Self {
size,
Expand All @@ -475,7 +475,7 @@ macro_rules! define_bitmap {
#[inline]
pub const fn from_bytes(bytes: &'a [$inner_type], size: Size) -> Self
where
<Self as Drawable>::ColorType: ~const ColorTrait
<Self as Drawable>::ColorType: ~const PixelColor
{
Self {
size,
Expand All @@ -495,24 +495,14 @@ macro_rules! define_bitmap {
}

impl<'a> [<BitmapRefMut $suffix>]<'a> {
#[inline]
pub const fn as_const(&'a self) -> &'a [<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}

#[inline]
pub const fn into_const(self) -> [<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}

#[inline]
pub const fn from_slice(
slice: &'a mut [$slice_type],
size: Size,
stride: Option<NonZeroUsize>,
) -> Self
where
<Self as Drawable>::ColorType: ~const ColorTrait
<Self as Drawable>::ColorType: ~const PixelColor
{
Self {
size,
Expand All @@ -527,7 +517,7 @@ macro_rules! define_bitmap {
#[inline]
pub const fn from_bytes(bytes: &'a mut [$inner_type], size: Size) -> Self
where
<Self as Drawable>::ColorType: ~const ColorTrait
<Self as Drawable>::ColorType: ~const PixelColor
{
Self {
size,
Expand All @@ -537,7 +527,17 @@ macro_rules! define_bitmap {
}

#[inline]
pub fn clone_mut(&'a mut self) -> Self {
pub const fn as_const(&'a self) -> &'a [<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}

#[inline]
pub const fn into_const(self) -> [<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}

#[inline]
pub fn clone_mut(&'a mut self) -> [<BitmapRefMut $suffix>]<'a> {
let slice = unsafe { &mut *self.slice.get() };
Self {
size: self.size(),
Expand Down Expand Up @@ -594,6 +594,13 @@ macro_rules! define_bitmap {
}
}

impl<'a> Borrow<[<BitmapRef $suffix>]<'a>> for [<BitmapRefMut $suffix>]<'a> {
#[inline]
fn borrow(&self) -> &[<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}
}

impl ToOwned for [<BitmapRefMut $suffix>]<'_> {
type Owned = [<OwnedBitmap $suffix>];

Expand All @@ -618,13 +625,27 @@ macro_rules! define_bitmap {
}
}

impl<'a> Borrow<[<BitmapRef $suffix>]<'a>> for [<OwnedBitmap $suffix>] {
#[inline]
fn borrow(&self) -> &[<BitmapRef $suffix>]<'a> {
unsafe { transmute(self) }
}
}

impl<'a> Borrow<[<BitmapRefMut $suffix>]<'a>> for [<OwnedBitmap $suffix>] {
#[inline]
fn borrow(&self) -> &[<BitmapRefMut $suffix>]<'a> {
unsafe { transmute(self) }
}
}

impl<'a> BorrowMut<[<BitmapRefMut $suffix>]<'a>> for [<OwnedBitmap $suffix>] {
#[inline]
fn borrow_mut(&mut self) -> &mut [<BitmapRefMut $suffix>]<'a> {
unsafe { transmute(self) }
}
}

}
};
( $suffix:tt, $inner_type:ty, $color_type:ty, ) => {
Expand Down Expand Up @@ -779,7 +800,7 @@ macro_rules! define_bitmap {

impl DrawGlyph for [<BitmapRefMut $suffix>]<'_> {}

impl BasicDrawing for [<BitmapRefMut $suffix>]<'_> {
impl DrawRect for [<BitmapRefMut $suffix>]<'_> {
fn fill_rect(&mut self, rect: Rect, color: Self::ColorType) {
let mut width = rect.width();
let mut height = rect.height();
Expand Down Expand Up @@ -891,9 +912,9 @@ macro_rules! define_bitmap {

define_bitmap!(8, u8, IndexedColor,);
define_bitmap!(16, u16, RGB565,);
define_bitmap!(32, u32, BGRA8888,);
define_bitmap!(32, u32, ARGB8888,);

impl BltConvert<BGRA8888> for BitmapRefMut8<'_> {}
impl BltConvert<ARGB8888> for BitmapRefMut8<'_> {}
impl BltConvert<IndexedColor> for BitmapRefMut8<'_> {}

impl BitmapRefMut8<'_> {
Expand Down Expand Up @@ -937,11 +958,11 @@ impl BitmapRefMut8<'_> {
}
}

impl BltConvert<BGRA8888> for BitmapRefMut32<'_> {}
impl BltConvert<ARGB8888> for BitmapRefMut32<'_> {}
impl BltConvert<IndexedColor> for BitmapRefMut32<'_> {}

impl BitmapRefMut32<'_> {
pub fn blend_rect(&mut self, rect: Rect, color: BGRA8888) {
pub fn blend_rect(&mut self, rect: Rect, color: ARGB8888) {
let rhs = color.components();
if rhs.is_opaque() {
return self.fill_rect(rect, color);
Expand Down Expand Up @@ -1034,7 +1055,7 @@ impl BitmapRefMut32<'_> {

pub fn blt8(&mut self, src: &BitmapRef8, origin: Point, rect: Rect, palette: &[u32; 256]) {
self.blt_convert(src, origin, rect, |c| {
BGRA8888::from_argb(palette[c.0 as usize])
ARGB8888::from_argb(palette[c.0 as usize])
});
}

Expand Down Expand Up @@ -1290,7 +1311,7 @@ impl DrawGlyph for BitmapRefMut<'_> {
}
}

impl BasicDrawing for BitmapRefMut<'_> {
impl DrawRect for BitmapRefMut<'_> {
#[inline]
fn fill_rect(&mut self, rect: Rect, color: Self::ColorType) {
match self {
Expand Down Expand Up @@ -1453,7 +1474,7 @@ pub struct OperationalBitmap {
vec: Vec<u8>,
}

impl ColorTrait for u8 {}
impl PixelColor for u8 {}

impl const Drawable for OperationalBitmap {
type ColorType = u8;
Expand Down Expand Up @@ -1976,7 +1997,7 @@ mod memory_colors {
}

#[inline]
pub fn _memset_colors32(slice: &mut [BGRA8888], cursor: usize, count: usize, color: BGRA8888) {
pub fn _memset_colors32(slice: &mut [ARGB8888], cursor: usize, count: usize, color: ARGB8888) {
for v in unsafe { slice.get_unchecked_mut(cursor..cursor + count) }.iter_mut() {
*v = color;
}
Expand All @@ -1985,9 +2006,9 @@ mod memory_colors {
// Alpha blending
#[inline]
pub fn _memcpy_blend32(
dest: &mut [BGRA8888],
dest: &mut [ARGB8888],
dest_cursor: usize,
src: &[BGRA8888],
src: &[ARGB8888],
src_cursor: usize,
count: usize,
) {
Expand All @@ -1999,7 +2020,7 @@ mod memory_colors {
}
}

define_bitmap!(1, u8, OneBitColor, Octet,);
define_bitmap!(1, u8, Monochrome, Octet,);

impl BitmapRef1<'_> {
#[inline]
Expand Down
Loading

0 comments on commit af98728

Please sign in to comment.