OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Jul 15, 2019 6:00 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Building UEFI Applications on Windows using NASM
PostPosted: Sat Dec 22, 2018 4:47 am 
Offline

Joined: Sat Dec 22, 2018 4:33 am
Posts: 3
I recently started writing a series of articles on operating system development using Windows.

I thought you guys might be interested. I have the first part up showing how a UEFI application can be written using NASM.

Quote:
This is a series of articles on developing your own operating system. We will be focusing on modern techniques, like UEFI booting and 64-bit assembly, and everything will be created from scratch. I will be going step-by-step, explaining every tool we use and every line of code, so that you have a thorough understanding of the process. You should be able to copy-paste these steps and get the same results I am describing.

In addition, we will be doing this on Windows and using the tools available on this platform only. OS development is almost exclusively done on UNIX-like systems because the tools are more readily available and documented. I hope to show you how easy this is to do on Windows too.


Top
 Profile  
 
 Post subject: Re: Building UEFI Applications on Windows using NASM
PostPosted: Sat Dec 22, 2018 8:56 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 324
Hi,

Good job! I have some constructive notes, if you don't mind.

About the Webpage
I have some displaying problem with the command line examples (eg.: diskpart). Everything is in one line, no breaks, no spaces either between the prompt and the command. I suppose this is a CSS issue. The code example (which does not have a prompt part) is fine.

About Code
Do you have any particular reason to use nasm? Fasm seems to be a better choice:
- written primarly for windows, and also has a small, fast, and really nice IDE (so you don't have to install Visual Studio if you don't want to)
- you can create EFI executables with fasm directly, no linker needed (much simpler toolchain)
- supports the same Intel syntax as nasm, although there are minor differences with macros (imho fasm's macros are more mature)
(Don't get me wrong, there's nothing wrong with nasm, it's just fasm seems to provide an easier development environment)

About the code itself, you should save rcx first, because that contains the ImageHandle which you might need later. Also, you assume rdx points to the system table, it would be better to check that with "rdx!=0 && *rdx==0x20494249" just to be sure (not that you have any meaningful way to report error if rdx is not valid, but you could return right away to avoid certain misbehaviour and maybe damaging the computer for good).

Other than these, your page is really nice, we should have more tutorials like this! I particularly like very much that you're using diskpart for mounting the image. Thank you for sharing with us! Oh, and your header image is just so cool. Has a certain cyberpunk feeling in it, and I like that it defies the bias that coders must be men! :-)

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: Building UEFI Applications on Windows using NASM
PostPosted: Sun Dec 23, 2018 12:02 am 
Offline

Joined: Sat Dec 22, 2018 4:33 am
Posts: 3
Quote:
I have some displaying problem with the command line examples (eg.: diskpart). Everything is in one line, no breaks, no spaces either between the prompt and the command. I suppose this is a CSS issue. The code example (which does not have a prompt part) is fine.

Oh, interesting. I wasn’t seeing any display issues when I tested. What browser and device (desktop or mobile) are you using? If you don’t mind me asking. I will look into fixing that.

Quote:
Do you have any particular reason to use nasm? Fasm seems to be a better choice

Those are all great points. I do love that there is no linker needed. But there is so many more resources, books, tutorials, etc you can find for NASM. If you get stuck on something in FASM, and the official docs don’t cover your issue, then your basically SOL or dependent on some kind stranger to help you on their forums.

I also haven’t seen a UEFI application written in NASM before, and so I did want to see how hard it would be to do :)

Quote:
About the code itself, you should ...

Thank you for this feedback. I was trying to keep it as simple as possible to start, but those are good points. I will incorporate those changes when I expand on the app in the next post.

Quote:
Other than these, your page is really nice, we should have more tutorials like this! I particularly like very much that you're using diskpart for mounting the image. Thank you for sharing with us! Oh, and your header image is just so cool. Has a certain cyberpunk feeling in it, and I like that it defies the bias that coders must be men!

Thank you very much! I appreciate the thoughtful feedback :)

Yes, I am going for a Cyberpunk look there and trying to post things related to cybernetics, vr and systems programming. I am working with a writer too and will have some original Cyberpunk fiction posted in the next few weeks, if you’re into that sort of thing.

Cheers!


Top
 Profile  
 
 Post subject: Re: Building UEFI Applications on Windows using NASM
PostPosted: Sun Dec 23, 2018 12:17 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 324
HackerPulp wrote:
Oh, interesting. I wasn’t seeing any display issues when I tested. What browser and device (desktop or mobile) are you using? If you don’t mind me asking. I will look into fixing that.
I have attached a screenshot. Was taken using Firefox on Linux. I think "pre strong { clear: both; }" or "pre strong { display: block; }" should do it without messing up other browsers.

Quote:
Those are all great points. I do love that there is no linker needed. But there is so many more resources, books, tutorials, etc you can find for NASM. If you get stuck on something in FASM, and the official docs don’t cover your issue, then your basically SOL or dependent on some kind stranger to help you on their forums.
Okay, you don't have to defend nasm :-) I was just curious why YOU picked that, and wondered if you were not aware of fasm. You are right about everything, but I'd like to point out fasm is pretty well documented, has a very strong user basis, and it's forum is just great. The original creator, Tomasz is frequently answering questions there. I haven't got stuck with fasm, like ever :-)

Quote:
I also haven’t seen a UEFI application written in NASM before, and so I did want to see how hard it would be to do :)
Now see, that's the difference. You can find lots of documents about using fasm with UEFI
x86asm's article
MrFox's tutorial
On x86_64 UEFI support
Examples on github
Our Lovecraftian fasm library for UEFI
But maybe you're right, it's time to do the same with NASM too. ;-)

Quote:
Thank you for this feedback. I was trying to keep it as simple as possible to start, but those are good points. I will incorporate those changes when I expand on the app in the next post.
...
Thank you very much! I appreciate the thoughtful feedback :)
You're welcome!

Quote:
Yes, I am going for a Cyberpunk look there and trying to post things related to cybernetics, vr and systems programming. I am working with a writer too and will have some original Cyberpunk fiction posted in the next few weeks, if you’re into that sort of thing.

Cheers!
Yep, looks like a great choice for such a page. I'm not really into that (I used to, long ago when I was young, and I have to admit I liked Neuromancer, Thakesi Kovacs' adventures very much, and of course the movie Blade Runner is just unbeatable (although the original book was not cyberpunk) :-) I wouldn't call myself a hardcore fan, mostly because I equally enjoyed Doctorow's Little Brother for example.

Anyway, I wish you good luck, and keep up the good work!

Cheers,
bzt


Attachments:
hackerpulp.png
hackerpulp.png [ 21.99 KiB | Viewed 508 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], pat, zaval and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group