#include #include "fns.h" #include "efi.h" typedef struct { UINT64 Revision; void *Open; void *Close; void *Delete; void *Read; void *Write; void *GetPosition; void *SetPosition; void *GetInfo; void *SetInfo; void *Flush; void *OpenEx; void *ReadEx; void *WriteEx; void *FlushEx; } EFI_FILE_PROTOCOL; typedef struct { UINT64 Revision; void *OpenVolume; } EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; static EFI_GUID EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID = { 0x0964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b, }; static EFI_FILE_PROTOCOL *fsroot; static void towpath(CHAR16 *w, int nw, char *s) { int i; for(i=0; *s && iOpen, fsroot, &fp, wname, (UINT64)1, (UINT64)1)) return nil; return fp; } static int fsread(void *f, void *data, int len) { UINTN size; size = len; if(eficall(((EFI_FILE_PROTOCOL*)f)->Read, f, &size, data)) return 0; return (int)size; } static void fsclose(void *f) { eficall(((EFI_FILE_PROTOCOL*)f)->Close, f); } void* fsinit(void) { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; fs = nil; fsroot = nil; if(eficall(ST->BootServices->LocateProtocol, &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, nil, &fs)) return nil; if(eficall(fs->OpenVolume, fs, &fsroot)){ fsroot = nil; return nil; } read = fsread; close = fsclose; open = fsopen; return fsopen("/plan9.ini"); }