/*
* Copyright ( c ) 2025 , Google , Inc . All rights reserved
*
* Permission is hereby granted , free of charge , to any person obtaining
* a copy of this software and associated documentation files
* ( the " Software " ) , to deal in the Software without restriction ,
* including without limitation the rights to use , copy , modify , merge ,
* publish , distribute , sublicense , and / or sell copies of the Software ,
* and to permit persons to whom the Software is furnished to do so ,
* subject to the following conditions :
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT .
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT ,
* TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
*/
#define LOCAL_TRACE 0
#include <lib/dtb_service/dtb_service.h>
#include <libfdt.h>
#include <lk/trace.h>
#include <stdint.h>
#include <uapi/err.h>
#include "instance_id.h"
static int convert_fdt_err(int err) {
if (err == -FDT_ERR_NOTFOUND) {
return ERR_NOT_FOUND;
}
return ERR_NOT_VALID;
}
int get_instance_id(const uint8_t** instance_id_ptr) {
int rc;
const uint8_t* dtb;
size_t dtb_size;
const uint8_t* ptr;
int offset;
int size;
rc = dtb_get(&dtb, &dtb_size);
if (rc < 0 ) {
LTRACEF("error getting DTB (%d)\n" , rc);
return rc;
}
offset = fdt_path_offset(dtb, "/avf/untrusted" );
if (offset < 0 ) {
LTRACEF("error finding AVF node (%d)\n" , offset);
return convert_fdt_err(offset);
}
ptr = fdt_getprop(dtb, offset, "instance-id" , &size);
if (!ptr) {
LTRACEF("instance-id property error (%d)\n" , size);
return convert_fdt_err(size);
}
for (int i = 0 ; i < size; i++) {
LTRACEF("instance_id[%d]=0x%02" PRIx8 "\n" , i, ptr[i]);
}
*instance_id_ptr = ptr;
return size;
}
Messung V0.5 in Prozent C=91 H=96 G=93
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-27)
¤
*© Formatika GbR, Deutschland