* EDK debug question
@ 2018-01-24 6:31 JUNWEN JIA
2018-01-24 6:55 ` Andrew Fish
0 siblings, 1 reply; 5+ messages in thread
From: JUNWEN JIA @ 2018-01-24 6:31 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Andrew Fish
Hi, Andrew:
Thanks for your reply. What I was trying is to restart my computer after 1 minute shutdown in shell. That is why I need to get .efi file through EDK.
The following is the assembly language I wrote in Reboot.asm, and I put this file in BaseLib->Ia32,along with Reboot.asm, Reboot.c.
.code
Reboot PROC
mov al,0bh
out 70h,al
mov al,20h
out 71h,al ;enable RTC interrupt
mov al,01h
out 70h,al
mov al,00h
out 71h,al
mov al,03h
out 70h,al
mov al,01h
out 71h,al
mov al,05h
out 70h,al
mov al,12h
out 71h,al ;wirte cmos alarm
mov al,00h
out 70h,al
mov al,00h
out 71h,al
mov al,02h
out 70h,al
mov al,00h
out 71h,al
mov al,04h
out 70h,al
mov al,12h
out 71h,al ;set cmos time
ret
Reboot ENDP
END
Best regards!
发送自 Windows 10 版邮件应用
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: EDK debug question
2018-01-24 6:31 EDK debug question JUNWEN JIA
@ 2018-01-24 6:55 ` Andrew Fish
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Fish @ 2018-01-24 6:55 UTC (permalink / raw)
To: JUNWEN JIA; +Cc: edk2-devel@lists.01.org
Yea don't do that.
1st off EFI does not assume the PC hardware from 1984 exists in your system like the old PC BIOS.
There are EFI services that abstract these hardware features.
gRT->SetWakeupTime()
gRT->ResetSystem()
You can lookup in the Services - Runtime Services chapter of the UEFI Spec for details.
To use gRT you will need to #include <Library/UefiRuntimeServicesTableLib.h> and list UefiRuntimeServicesTableLib in the [LibraryClasses] section of the .INF file to make the gRT global compile and link in your App.
Also even though you should NOT do this you could write your RTC code using the IoLib via inb is IoRead8() and outb is IoWrite8() C API and you don't have to write it in assembler.
Thanks,
Andrew Fish
> On Jan 23, 2018, at 10:31 PM, JUNWEN JIA <jiajunwen123@gmail.com> wrote:
>
> Hi, Andrew:
> Thanks for your reply. What I was trying is to restart my computer after 1 minute shutdown in shell. That is why I need to get .efi file through EDK.
> The following is the assembly language I wrote in Reboot.asm, and I put this file in BaseLib->Ia32,along with Reboot.asm, Reboot.c.
> .code
> Reboot PROC
> mov al,0bh
> out 70h,al
> mov al,20h
> out 71h,al ;enable RTC interrupt
> mov al,01h
> out 70h,al
> mov al,00h
> out 71h,al
> mov al,03h
> out 70h,al
> mov al,01h
> out 71h,al
> mov al,05h
> out 70h,al
> mov al,12h
> out 71h,al ;wirte cmos alarm
> mov al,00h
> out 70h,al
> mov al,00h
> out 71h,al
> mov al,02h
> out 70h,al
> mov al,00h
> out 71h,al
> mov al,04h
> out 70h,al
> mov al,12h
> out 71h,al ;set cmos time
> ret
> Reboot ENDP
> END
>
>
> Best regards!
>
> 发送自 Windows 10 版邮件应用
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* EDK debug question
@ 2018-01-24 8:30 JUNWEN JIA
0 siblings, 0 replies; 5+ messages in thread
From: JUNWEN JIA @ 2018-01-24 8:30 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Andrew Fish
Hi, Andrew:
Thanks a lot and I really appreciate your suggestion. But the assembly language code is for getting started,
and I may have to write C language embedded with assembly language and compile through EDK. That is why
I have to use assembly language to achieve the restart function.
And I have some doubts, if I call functions that already exists in BaseLib->Ia32,for example:
#include<Library/BaseLib.h>
Void main()
{
WriteMsr64(0,0);
}
This can be compiled successfully and .efi file can be generated.
Best regards!
发送自 Windows 10 版邮件应用
^ permalink raw reply [flat|nested] 5+ messages in thread
* EDK debug question
@ 2018-01-24 2:23 JUNWEN JIA
2018-01-24 3:00 ` Andrew Fish
0 siblings, 1 reply; 5+ messages in thread
From: JUNWEN JIA @ 2018-01-24 2:23 UTC (permalink / raw)
To: edk2-devel@lists.01.org
Hi:
Thanks for your replies. I referred to some examples in baselib, for example,WriteMsr64.asm, WriteMsr64.nasm,
WriteMsr64.c and create Reboot.asm, Reboot.nasm, Reboot.c file in MdePkg->Library->BaseLib-> Ia32. I also made some
corresponding Changes in BaseLib.inf and other files. And I did avoid to use X64 arch. So my cmos.c source file in AppPkg is like
this:
#include<Library/BaseLib.h>
Void main()
{
Reboot();
}
But the compiled result is Reboot.lib(Reboot.obj):error LNK2001:
####\DEBUG\cmos.dll:fatal error LINK1120:1
The picture is the compiled result, and I wonder if I missed to create or modify some files?
Thanks for helping !
Best Regards!
发送自 Windows 10 版邮件应用
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: EDK debug question
2018-01-24 2:23 JUNWEN JIA
@ 2018-01-24 3:00 ` Andrew Fish
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Fish @ 2018-01-24 3:00 UTC (permalink / raw)
To: JUNWEN JIA; +Cc: edk2-devel@lists.01.org
> On Jan 23, 2018, at 6:23 PM, JUNWEN JIA <jiajunwen123@gmail.com> wrote:
>
> Hi:
> Thanks for your replies. I referred to some examples in baselib, for example,WriteMsr64.asm, WriteMsr64.nasm,
> WriteMsr64.c and create Reboot.asm, Reboot.nasm, Reboot.c file in MdePkg->Library->BaseLib-> Ia32. I also made some
> corresponding Changes in BaseLib.inf and other files. And I did avoid to use X64 arch. So my cmos.c source file in AppPkg is like
You should not be modifying the BaseLib, that is like changing the C Lib for an App.
Maybe we should start with what you are trying to write in assembler as there is no portable way to reboot a system from assembler.
Thanks,
Andrew Fish
> this:
> #include<Library/BaseLib.h>
> Void main()
> {
> Reboot();
> }
> But the compiled result is Reboot.lib(Reboot.obj):error LNK2001:
> ####\DEBUG\cmos.dll:fatal error LINK1120:1
>
> The picture is the compiled result, and I wonder if I missed to create or modify some files?
>
> Thanks for helping !
> Best Regards!
>
>
> 发送自 Windows 10 版邮件应用
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-24 8:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-24 6:31 EDK debug question JUNWEN JIA
2018-01-24 6:55 ` Andrew Fish
-- strict thread matches above, loose matches on Subject: below --
2018-01-24 8:30 JUNWEN JIA
2018-01-24 2:23 JUNWEN JIA
2018-01-24 3:00 ` Andrew Fish
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox