WFU

[ 精選文章 ]

自行車 入門 Escape 3 , Snap 21 , Revel

最近周末想運動 , 平日想通勤 , 想買台自行車 , 把自己找的資料跟大家分享 , 如果你是玩家級的 就不用看了 這是給跟我一樣的新新新手 參考的 騎車半年後的補充: 如果你有把握你是真的有時間有興趣會一直騎,建議還是存點錢買好一點的彎把公路車, 或是可以考慮買2手的自...

2016年2月19日 星期五

EFI Related

Delay()

方法一:使用UEFI內建函數
1
gBS->Stall(Microsecond);
     使用Stall要注意如下
#include <Library/UefiBootServicesTableLib.h>
Stall以微秒(µs,10-6)為單位

方法二:使用標準C Library的函數
1
sleep(second);
     使用sleep要注意如下
#include <Include/unistd.h>
inf中,在[LibraryClasses]添加LibC
sleep以秒為單位
pST  = SystemTable
gBS = SystemTable->BootServices)
UDK: #include <Library/UefiBootServicesTableLib.h>


MdePkg.dec
TimerLib
#include <Library/TimerLib.h>
MicroSecondDelay()

===================
EVENT
CreateEventEx 為事件組 一個 event 被觸發 就全部都跑一遍 (優先權為 先看TPL 在來是晚註冊的先跑)
EFI_EVENT Event;
EFI_GUID gGuid = EFI_MY_GUID;
gBS->CreateEventEx (0, 0, NULL, NULL,&gGuid,&Event);
gBS->SignalEvent (Event);
gBS->CloseEvent (Event);

原型:
CoreCreateEventEx (
  IN UINT32                   Type,
  IN EFI_TPL                  NotifyTpl,
  IN EFI_EVENT_NOTIFY         NotifyFunction, OPTIONAL
  IN CONST VOID               *NotifyContext, OPTIONAL
  IN CONST EFI_GUID           *EventGroup,    OPTIONAL
  OUT EFI_EVENT               *Event
  );


1.If a UEFI Driver creates events in its  driver entry point, those events must be closed with CloseEvent() in the UEFI Driver's Unload() function
2.If a UEFI Driver creates events in its Driver Binding Protocol Start()function associated with a device, those events must be closed with CloseEvent() in its Driver Binding Protocol  Stop() function.
3.If a UEFI Driver creates events as part of an  I/O operation, the event should be closed with CloseEvent() when the I /O operation is completed.




Adding the Unload Feature

https://blog.csdn.net/CStyle_0x007/article/details/8945459

https://blog.csdn.net/luobing4365/article/details/104552594

https://blog.csdn.net/stringNewName/article/details/80004887


extern EFI_BOOT_SERVICES *gBS;
extern EFI_SYSTEM_TABLE *gST;
extern EFI_RUNTIME_SERVICES *gRT;

InitAmiLib()
pST = SystemTable;
pBS = pST->BootServices;
pRS = pST->RuntimeServices;

#define gBS pBS
#define gRT pRS

gST = pST;
gBS = pBS;
gRT = pRS;

To enable the wake function in BLUE TOOTH DEVICE

After that , According to MSFT , there are some registry should be modified.

https://support.microsoft.com/zh-tw/kb/975182
https://msdn.microsoft.com/en-us/library/windows/hardware/dn133849(v=vs.85).aspx

• HKLM\System\CurrentControlSet\Services\Bthport\Parameters \SystemRemoteWakeSupported : (DWORD) 1
• HKLM\System\CurrentControlSet\Enum\USB\\ \Device Parameters\RemoteWakeEnabled : (DWORD) 1
• HKLM\System\CurrentControlSet\Enum\USB\\ \Device Parameters\DeviceRemoteWakeSupported : (DWORD) 1

2016年2月17日 星期三

7Z 壓縮 SVN folder

複製貼上下方文字為 batch file , 拖曳欲壓縮的資料夾在 batch file 上即可自動生成 7Z 文件
(不壓縮 .svn Build Conf 等目錄)

@echo off
::Batch File to Auto Creat BIOS source code backup , ignore Build , .SVN , CONF folder
::Usage , Drag and Drop the Folder to be backup to the Batch file
::Rewolf @ 2016/02/17

set ZG=C:\Program Files\7-Zip\7zG.exe
for %%a in (%*) do (dir /a %%a|findstr "DIR" >nul 2>nul && ("%ZG%" a -r -mx9 -xr!build -xr!conf -xr!.svn "%%~dpa%%~na.7z" "%%~a"))
set ZG=
echo on

2016年2月3日 星期三

UEFI SHELL Reboot counter

Startup.nsh
========================
echo -off
set StartupDelay 0

#if Counter is not exist , set to 0
if exist %Counter% then
set Counter 0
endif


#check Counter from 0-19999
#About 13 sec in each reboot , Can cover 72 HR long run test
#if match , set myFlag , Counter will +1 in next loop

for %a run (%Counter% 19999)
    if %Counter% == %a then
        set myFlag 1
    else
        if %myFlag% == 1 then
            set myFlag 0
            set Counter %a
            goto Leave_For
        endif
    endif
endfor
:Leave_For

echo Loop Cycle = %Counter%

reset

echo -on