/*--------------------------------------------------------------------------*
シリアルナンバー取得
*--------------------------------------------------------------------------*/
#include <nn.h>
#include <nn/cfg.h>
#include <nn/cfg/CTR/cfg_ApiInit.h>
#include "sys.h"
#include "sys_GetSerialNumber.h"

/************************************************************************
シリアルナンバーの取得
 ************************************************************************/

void uji::sys::GetSerialNumber( char* serial )
{
    // シリアルはプログラム上で動的に変更できるので
    // あえて毎回読み込むようにしています。
    nn::Result result;
    nn::cfg::CTR::detail::SecureInfoBody secInfo;
    result = nn::cfg::CTR::init::GetSecureInfoBody( &secInfo );
    if( result.IsFailure())
    {
        SYS_PANIC( "Fail to Get Serial Number" );
    }

    std::memset( serial, 0x00, nn::cfg::CTR::detail::CFG_SECURE_INFO_SERIAL_NO_LEN+1);
    std::memcpy( serial, secInfo.serialNo, nn::cfg::CTR::detail::CFG_SECURE_INFO_SERIAL_NO_LEN );

}

