bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.63k stars 104 forks source link

UEFI program compile error #99

Closed xiaoyuvax closed 11 months ago

xiaoyuvax commented 1 year ago

compiling the single file of following code with --os:uefi --stdlib:zero throws error

using Internal.Runtime.CompilerHelpers;
using System;

namespace UEFI.App;

internal unsafe class Program
{
    private static void Main()
    { }

    [System.Runtime.RuntimeExport("EfiMain")]
    private static long EfiMain(IntPtr imageHandle, EFI_SYSTEM_TABLE* systemTable)
    {
        string hello = "Hello world!";
        fixed (char* pHello = hello)
        {
            systemTable->ConOut->OutputString(systemTable->ConOut, pHello);            
        }

        while (true) ;
    }
}

error output:

D:\Repos\UEFIApp\efimain.cs(14,53): error CS0246: The type or namespace name 'EFI_SYSTEM_TABLE' could not be found (are you missing a using directive or an assembly reference?)
D:\Repos\UEFIApp\efimain.cs(13,21): error CS0122: 'RuntimeExportAttribute' is inaccessible due to its protection level
MichalStrehovsky commented 1 year ago

With stdlib zero you just write a Main as usual and use System.Console.WriteLine as usual. See the snake sample in the repo.

xiaoyuvax commented 1 year ago

oic, i have to get reference to SystemTable this way, right? EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;

MichalStrehovsky commented 1 year ago

System table is not exposed from zerolib. You need to do --stdlib:none and implement everything yourself.