JoshuaWierenga / EfiSharp

An Attempt at building at least some of C# corelib for EFI applications. Inspired by https://github.com/MichalStrehovsky/zerosharp to see if this possible.
MIT License
18 stars 4 forks source link

Specify custom entry point #12

Closed kant2002 closed 3 years ago

kant2002 commented 3 years ago

https://github.com/JoshuaWierenga/EfiSharp/blob/13532be5da2ec36c3f16228fae616f4addb80632/samples/csharp/branches-quickstart/BranchesAndLoops.csproj#L25

See https://github.com/dotnet/runtimelab/pull/633, you can now specify <EntryPointSymbol>EfiMain</EntryPointSymbol>

JoshuaWierenga commented 3 years ago

Thanks for reminding me, I only updated the main project so far. The plan is to move the build stuff out of csproj so that it can be reused for without having to use the template project at https://github.com/JoshuaWierenga/EfiSharp/blob/main/samples/TemplateProject. Ideally making an efi project should be identical to any other .net project with the build system just dealing with the differences. Since I am nowhere close to doing that I should probably update the sample projects to at least match the main project.

kant2002 commented 3 years ago

I probably have to unveil what I have here. It's already possible to build like that with small (or large) caveat. Runtime library is not on Nuget, and if even that, it would not allow use existing Nuget packages which is big miss IMO.

JoshuaWierenga commented 3 years ago

You are right about not being able to use nuget packages being a problem, Ideally, I would be able to add more features from system.private.corelib at some point to make more work but I guess not soon. I do plan to add time and file support sometime soon, though I am not sure what file systems are supported by efi, fat32/exfat?

Edit: Just fat https://uefi.org/sites/default/files/resources/UEFI%20Spec%202.8B%20May%202020.pdf#page=578

kant2002 commented 3 years ago

Let me share what I have. I already have some graphics support, so you can borrow that. Also I think would be good to create shared repository so we can both improve UEFI structures coverage.

JoshuaWierenga commented 3 years ago

Potentially of interest is https://github.com/JoshuaWierenga/EfiSharp/tree/Test.CoreLib-libc where I removed my custom MathHelpers.cpp and managed to use the actual MathHelpers.obj from the full runtime.lib provided with ilcompiler.

There is also https://github.com/Michael-Kelley/RoseOS, this project also has graphics but more interesting, includes the ability to run the cut down runtime on windows which might allow debugging.

kant2002 commented 3 years ago

Want to actually implement simple Libc in C#. Potentially. Or integrate existing libc + threads to start poking with GC inside UEFI. Thanks for the hints.

JoshuaWierenga commented 3 years ago

I was using parts of mlibc since it is a freestanding library, I doubt its memory functions will work while in efi boot services. Our options would be either to leave efi boot services or to just use the efi memory functions like I have and then add a c wrapper like posix-uefi.

JoshuaWierenga commented 3 years ago

On second look, it appears mlibc does not have malloc since it varies too much by platform and so mlibc + posix-uefi is an option.

Edit: mlibc or something like it would be good since it is designed to be ported to new platforms.

JoshuaWierenga commented 3 years ago

Let me share what I have. I already have some graphics support, so you can borrow that. Also I think would be good to create shared repository so we can both improve UEFI structures coverage.

@kant2002 Did you mean you would upload in your own repo or on this one? Either is fine I would just have to give you access I think.

kant2002 commented 3 years ago

I think about sharing in separate repo. I do not think Iā€™m ready to publish everything what I already have. Let me think about it

On Mon, Feb 8, 2021 at 15:06 Joshua Wierenga notifications@github.com wrote:

Let me share what I have. I already have some graphics support, so you can borrow that. Also I think would be good to create shared repository so we can both improve UEFI structures coverage.

@kant2002 https://github.com/kant2002 Did you mean you would upload in your own repo or on this one? Either is fine I would just have to give you access I think.

ā€” You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/JoshuaWierenga/EfiSharp/issues/12#issuecomment-774990986, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAPKNYLBRX6OC2D5JG4Y4DS56SSDANCNFSM4XIDT4VA .

JoshuaWierenga commented 3 years ago

Take your time. Regardless, thanks for prompting me to take a look at the sample projects. Short of a major bug turning up, https://github.com/JoshuaWierenga/EfiSharp/pull/13 appears to work well. It is now possible just to tell the build script what project to build. Additionally, only one line has to be added to a project's csproj file to enable it to act as a console project.

Since it is largely done with stock tools, I cannot imagine why nuget wouldn't work from a technical perspective. It is still mostly useless without compatible libraries but ones that do not use unsupported features should work.

JoshuaWierenga commented 3 years ago

@kant2002 Did you end up fixing the apphost issue, I have been getting this issue for months and always just end up putting a copy there myself. image I tried to disable apphost generation but that gives the apphost -> selfcontained -> compiling for size error thing you had.

kant2002 commented 3 years ago

<ComputeNETCoreBuildOutputFiles>false</ComputeNETCoreBuildOutputFiles>

kant2002 commented 3 years ago

You definitely can hang at https://gitter.im/dotnet/corert , because using GitHub as chat seems strange šŸ˜„

kant2002 commented 3 years ago

You need specify just

<ComputeNETCoreBuildOutputFiles>false</ComputeNETCoreBuildOutputFiles>

that way you don't need <UseAppHost>false</UseAppHost>

JoshuaWierenga commented 3 years ago

That works thanks, good point about gitter.im.