OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:22 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Wed Mar 29, 2017 5:08 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
Ok, since the work tonight is not working out, I've finally decided to write some short "announce" here. It's not really an announce, since there are no samples of the project doing much yet, but the code can already run on the hardware in question (mips machine) and it slowly is getting more functionality, so I put this topic, so that I will have a place to report progress or something, have answers and questions (probably), take advices, even overly lengthy. :D anything related.

It's a sub-project of my OS project and it's about creating a UEFI compliant implementation for a couple of arm and mips boards.
it's not based on Tianocore. I am creating it for educational purposes, to learn and test myself on ability to program HW. And, maybe it would be useful for others for the same reasons or even for the direct usage as a FW.

The target boards chosen are:
Mips Creator CI20 - mips32r2
Beagle Bone Black - armv7 (aarch32)
Cubieboard 2 - armv7 (aarch32)
Pine64+ - armv8 (aarch64)
Some settop box with RK3368 - armv8 (aarch64)

Only mips32 and aarch32 are somewhat touched by the project so far, aarch64 is not yet.
The project informally is called U3 as a shortening of uefi.upptech.ua - where "upptech" is a non-registered "organization" consisting of me as a developer. The OS is called ANT (and finally, its POSIX environment subsystem is called PussyX as my signature shows). :mrgreen:

The implementation has its main goal as to be a UEFI-conformant firmware for a few SBC. Those don't have it yet. So, there is a practical goal too, to bring UEFI support into the (mostly arm) SBC landscape.
It does follow the PI spec as well, but it's not a strict requirement, it's an internal implementation thing anyway, UEFI is the standard implemented. So for example it is split up into PI defined phases:

- SEC ("teh security", taking control of ROM code, a very basic initialization in fact)
- PEI (pre Efi init - SDRAM init mostly)
- DXE (driver execution environment, everything goes here, it's a UEFI "kernel", exactly it supplies UEFI Services for example)
- BDS (boot device selection, UEFI Boot Manager, dealing with boot policies, boot options, interaction with user)

we kind of follow this. But the Pei phase is omitted on the mips target. And will be omitted on armv7 targets too. There are reasons for this - it avoids unnecessary duplication between Dxe and Pei. We put Pei's responsibilty of inintializing SDRAM on the Sec blob, and everything else is done by Dxe. You will not be wondered to hear, that some EDK targets also omit the Pei phase. It doesn't look sane to do this split (between Pei and Dxe) on SoC based designs. Pei foundation has a very similar tasks and organization to the Dxe counterpart, still it differs and results in duplication. I mean PPI vs Protocols, PPI database vs Handle Table, PEIMs dispatching vs DXE drivers dispatching. Basically Pei has been invented as a little Dxe, for platforms where it's needed. Or for additional solidity, :D some other reasons. SoC based machines clearly will be happy with this phase fusion. :)

Mostly we are at the Sec stage. Some portions of UEFI services are written as well, but not tested yet. Handle table database (with protocols of course) organization is designed.
The Sec blob, SEC.SYS is written entirely in assembly - I said I want to learn HW programming. It's a format-less binary which is put where the ROM code expects it to be, for the SD card boot scenario (that we are using now), it's right after an MBR sector. Fortunately, the first partition lies so far away from this area, we can easily fit our entire FW into this spare area, not messing up with partitions. But this scenario is a beginning one. We need more permanent storage where it's present (not always it's the case on the SBC landscape, examples - Pine64+, our aarch64 target, Raspberry Pi, they don't have eMMC or NAND storages, only SD card slots) to store our FW. So with the progress, we migrate to NAND for the CI20 target.
Our SEC gets loaded by the ROM code into TCSM - tightly coupled shared memory, a SRAM area with only 14 KB of available space (this limitation was an initial reason we offcast the PEI phase).
So far SEC.SYS only can print into UART, starts PLLs and configures clocks for the CPU, L2 cache, AHB0 and AHB2 buses and for PCLK - peripheral clock, also it initializes the OS Timer. It plays with the LED, and has some support routines for printing.
Now we need to finally initialize SDRAM. Then configure SD controller and read our Dxe.exe PE file into SDRAM and load it as an executable. Then create HOB-list (jack off, sorry, - hand off blocks - needed for memory representation for Dxe) and jump to DxeEntryPoint(). Later, when we figure out what the security it really needs, we add it here, so far, practically, it's a fancy 1st stage bootloader for the rest of FW, if you want, but with an SDRAM initialization bonus inside.

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Sun Apr 09, 2017 7:52 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
minor fix. now the OS timer counts up. and everything is ready for starting the SDRAM init process. which is hard but not very learning and informative, not very giving you an experience. because you just reproduce what you've seen in u-boot, and they reproduced what they saw in Ingenic's BSP. Because the process is not documented well. So you are forced to act as a code monkey. :^/
Anyways, we tried to get an idea what things are for as much as we could.
we chose BASE 0x00, and MASK 0x80. Those are related to the most significant byte of SDRAM bus address (physical address) by the formula:
BUS_ADDR[31-24] & MASK == BASE
Given we have 1GB of SDRAM, with such a configuration we will have 2 subspaces of aliases - the lower 0x00000000-0x3fffffff and the higher 0x40000000-7fffffff pointing to the same SDRAM locations. Using the higher part, we hope to overcome the reserved (for I/O particularly) range 0x10000000-0x1fffffff. Hopefully, it's yet to be figured out, because again, the manual is sooo unclear (it's a censored version of its characteristic).
For example in a drawing it shows an arrow from address 0 pointing to the 0x20000000... What this means? That these (256MB in size) ranges are aliases too? But they couldn't be those, with the above configuration, which in turn is OK according to the DDRC part of the manual. Will I end up with space folding (overlapping) with this? Who knows, it will be needed to check this manually. Then again if 0x00 and 0x20 (in MSB) are aliases somehow, then will the pair 0x40-0x60 be aliases too? But wait, this way, we are losing 1/4 of address space for SDRAM! That's why there is no much enthusiasm to insert that (almost written) code and test it. *sigh*

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Wed May 10, 2017 1:20 am 
Offline
Member
Member

Joined: Sun Apr 23, 2017 4:41 am
Posts: 28
I'll jump in with some Aarch64 code if you'd like. I'm planning to write some firmware myself


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Thu May 11, 2017 1:16 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
Cool. Are you working on UEFI implementation for aarch64?
Honestly, for now, I am fully get stuck into mips, can't say anything on aarch64 which I am interested in of course, but for future, I even have two boards with this architecture.
If you mean some cooperation, it's all possible and even desirable, probably, but for now I am not ready to participate in aarch64. :)

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Fri May 12, 2017 2:16 am 
Offline
Member
Member

Joined: Sun Apr 23, 2017 4:41 am
Posts: 28
it's more of an initialization code (setting up acpi, pci, interrupts and so forward) but I imagine it'll be of great use for the aarch64 side of your uefi. You don't have to do any work, I'll just donate the code when im done with it :)


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Fri May 12, 2017 12:34 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
everybody loves (code) donations. :)
it was planned for this kind of development - providing a "framework" (UEFI Core (DXE+BDS), some build utilities, SDK, Tianocore shell ported) for UEFI implementations not covered by edk - low-end arm, mips. people then would add particular board support in it - supply board specific SEC bootstrap, Dxe drivers, basically adding new board support. but it's "ideally". so far it's just a mess. xD
of course, it would be nice to have others' effort incorporated, because it's unfeasible for 1 person - to do everything, anyway.)

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Sun May 14, 2017 1:57 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
i will follow your work, and i will possibly add a Dawn-compatible emulator to your code.

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: U3 (UEFI implementation for some arm and mips boards)
PostPosted: Fri May 19, 2017 12:22 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
^_^ that's flattering. on my side, I hope there will be something to follow for interested.)

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 27 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