UEFI port of Fdtlib
A message that is not in the archive (sent off-list or not yet received): 00cd01cc6f23$0c9f5990$25de0cb0$@[email protected]
A message that is not in the archive (sent off-list or not yet received): 00cd01cc6f23$0c9f5990$25de0cb0$@[email protected]
Quoted 42 lines · Olivier Martin
Hello all,
I have ported the libfdt to Tianocore project [1] (under BSD license) which is an implementation of UEFI specification supported by Intel, ARM Ltd and other major companies.
I took the libfdt directory from the head revision ofgit://git.jdl.com/software/dtc.gitand ported it to the Tianocore project. I had just needed to edit thelibfdt_env.hto translate the POSIX types and functions into their Tianocore equivalents.
I was advised to send my changes to this mailing-list (please find the editedlifdt_env.hattached to this email).I am using this libfdt library to add/update information to the Device Tree (Linux kernel cmd line, etc) that is passed to the Linux kernel. I am planning to push upstream my changes in the next couple of days.
Questions and comment are welcome !
Best Regards,
Olivier[1] http://sourceforge.net/apps/mediawiki/tianocore/
#ifndef
_LIBFDT_ENV_H
#define_LIBFDT_ENV_H#include <
Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>typedef UINT8
uint8_t;
typedef UINT32uint32_t;
typedef UINT64uint64_t;
typedef UINTNuintptr_t;
typedef UINTNsize_t;#define
_B(n)((unsigned long long)((uint8_t *)&x)[n])
static inlineuint32_tfdt32_to_cpu(uint32_t x){ return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); }#define
cpu_to_fdt32(x)fdt32_to_cpu(x)
Quoted 7 lines
static inline
uint64_tfdt64_to_cpu(uint64_t x){ return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); }#define
cpu_to_fdt64(x)fdt64_to_cpu(x)
#undef _B
Tianocore really doesn't have any byte swapping functions? I only used these nasty versions, because they're portable, whereas very little about userspace endian.h/bytesex.h is.
Quoted 7 lines
static inline void*
memcpy(void* dest, const void* src, size_t len){
return CopyMem (dest, src, len);
}static inline void *memmove(void *dest, const void *src,
size_tn) {
return CopyMem (dest, src, n);
}
Ok, I take it that Tianocore's CopyMem can operate on overlapping source and destination, like memmove()?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): 20110912013930.GL9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org
Thanks David for the feedback,
You right I should better use the Tianocore functions "UINT32 SwapBytes32(UINT32 Value)" and "UINT64 SwapBytes64(UINT64 Value)". And the Tianocore's CopyMem() supports the overlapped source and destination.
Olivier
-----Original Message-----
From: David Gibson [mailto:[email protected]]
Sent: 12 September 2011 02:40
To: Olivier Martin
Cc: devicetree-discuss-uLR06cmDAlY/[email protected]
Subject: Re: UEFI port of Fdtlib
Quoted 3 lines · Olivier Martin
Hello all,
I have ported the libfdt to Tianocore project [1] (under BSD license)
which
Quoted 5 lines
is an implementation of UEFI specification supported by Intel, ARM Ltd and other major companies.
I took the libfdt directory from the head revision ofgit://git.jdl.com/software/dtc.gitand ported it to the Tianocore project. I had just needed to edit thelibfdt_env.hto translate the POSIX types
and
Quoted 5 lines
functions into their Tianocore equivalents.
I was advised to send my changes to this mailing-list (please find the editedlifdt_env.hattached to this email).I am using this libfdt library to add/update information to the Device
Tree
Quoted 29 lines
(Linux kernel cmd line, etc) that is passed to the Linux kernel. I am planning to push upstream my changes in the next couple of days.
Questions and comment are welcome !
Best Regards,
Olivier[1] http://sourceforge.net/apps/mediawiki/tianocore/
#ifndef
_LIBFDT_ENV_H
#define_LIBFDT_ENV_H#include <
Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>typedef UINT8
uint8_t;
typedef UINT32uint32_t;
typedef UINT64uint64_t;
typedef UINTNuintptr_t;
typedef UINTNsize_t;#define
_B(n)((unsigned long long)((uint8_t *)&x)[n])
static inlineuint32_tfdt32_to_cpu(uint32_t x){ return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); }#define
cpu_to_fdt32(x)fdt32_to_cpu(x)
Quoted 7 lines
static inline
uint64_tfdt64_to_cpu(uint64_t x){ return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); }#define
cpu_to_fdt64(x)fdt64_to_cpu(x)
#undef _B
Tianocore really doesn't have any byte swapping functions? I only used these nasty versions, because they're portable, whereas very little about userspace endian.h/bytesex.h is.
Quoted 7 lines
static inline void*
memcpy(void* dest, const void* src, size_t len){
return CopyMem (dest, src, len);
}static inline void *memmove(void *dest, const void *src,
size_tn) {
return CopyMem (dest, src, n);
}
Ok, I take it that Tianocore's CopyMem can operate on overlapping source and destination, like memmove()?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson