CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.89k stars 546 forks source link

Resize MemoryBlock feature #1387

Open valentinbreiz opened 4 years ago

valentinbreiz commented 4 years ago

do a realloc equivalent for MemoryBlock class and fix the = new MemoryBlock problem if it is called again with a bigger size at the same offset.

the issue I was facing when trying to change VBE BGA modes:

Msg: Text from kernel: Creating a new bitmap from saved bitmap creates same bitmap
01:47:27.490766         Msg: Text from kernel: Testing Canvas with mode 1024x768@32
01:47:27.904688         Msg: Text from kernel: Test of Canvas with mode 1024x768@32 executed successfully
01:47:27.952705         Msg: Text from kernel: Testing Canvas with mode 800x600@32
01:47:28.759647         Msg: Text from kernel: Test of Canvas with mode 800x600@32 executed successfully
01:47:28.806602         Msg: Text from kernel: Testing Canvas with mode 1024x768@32
01:47:29.740571         Msg: Text from kernel: Test of Canvas with mode 1024x768@32 executed successfully
01:47:29.788581         Msg: Text from kernel: Testing Canvas with mode 1280x1024@32
01:47:30.075635         Msg: Text from kernel: Exception occurred: Specified argument was out of the range of valid values.

When the first mode was enabled (1024x768@32) a MemoryBlock of size 1024x768x4 was created. But for some reasons it blocks here. Once a MemoryBlock of a specific offset is created, it cannot be resized with higher size by calling again = new MemoryBlock. Indeed in the tests, it creates a Canva for each mode, and initialize the VBE driver each time and do each time a

IO.LinearFrameBuffer = new MemoryBlock(0xE0000000, (uint)xres * yres * (uint)(bpp / 8));

The "fix" I mean hijack was just to create a bigger MemoryBlock which can include all modes (1920x1080x4):

IO.LinearFrameBuffer = new MemoryBlock(0xE0000000, 1920 * 1200 * 4);
github-actions[bot] commented 3 years ago

Stale issue message