blob: 489967a73337b1ade43a44f15a3b85e2ed7f9e14 [file] [log] [blame]
/*
* Copyright (c) 2021 The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <common.h>
#include <malloc.h>
#include <asm/arch-qca-common/smem.h>
#define ANDROID_AB_SLOT_ARG "androidboot.slot_suffix"
const char *android_get_active_slot(void)
{
/* hard-code to slot "a" as of now */
if (get_rootfs_active_partition() == 0) {
return "_a";
} else {
return "_b";
}
}
void android_set_active_slot_bootargs(void)
{
int len;
char buffer[50];
char *oldargs, *newargs;
snprintf(buffer, sizeof(buffer), "%s=%s",
ANDROID_AB_SLOT_ARG, android_get_active_slot());
len = strlen(buffer) + 1;
oldargs = getenv("bootargs");
if (oldargs) {
len += (strlen(oldargs) + 1);
}
newargs = malloc(len);
if (newargs) {
newargs[0] = '\0';
if (oldargs) {
strcpy(newargs, oldargs);
strcat(newargs, " ");
}
strcat(newargs, buffer);
setenv("bootargs", newargs);
free(newargs);
}
}