ANDROID: Add macros to create reserved data fields to backport upstream changes

Adds various macros to create reserved data fields in kernel data
structures before the freeze and to use reserved data fields to backport
upstream changes after the freeze.

Bug: 233387627
Change-Id: Ifbf8444861fa805593ce9b4837cd2653b7b7a0b0
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
This commit is contained in:
Veerendranath Jakkam 2022-06-14 12:35:46 +05:30 committed by Carlos Llamas
parent 10f3543124
commit 3dc56c75d2
1 changed files with 38 additions and 0 deletions

View File

@ -15,6 +15,10 @@
#ifndef _ANDROID_VENDOR_H
#define _ANDROID_VENDOR_H
#include "android_kabi.h"
#define _ANDROID_BACKPORT_RESERVED(n) u64 android_backport_reserved##n
/*
* ANDROID_VENDOR_DATA
* Reserve some "padding" in a structure for potential future use.
@ -25,6 +29,13 @@
* ANDROID_VENDOR_DATA_ARRAY
* Same as ANDROID_VENDOR_DATA but allocates an array of u64 with
* the specified size
*
* ANDROID_BACKPORT_RESERVED
* Reserve some "padding" in a structure for potential future use while
* backporting upstream changes. This normally placed at the end of a
* structure.
* number: the "number" of the padding variable in the structure. Start with
* 1 and go up.
*/
#ifdef CONFIG_ANDROID_VENDOR_OEM_DATA
#define ANDROID_VENDOR_DATA(n) u64 android_vendor_data##n
@ -32,6 +43,7 @@
#define ANDROID_OEM_DATA(n) u64 android_oem_data##n
#define ANDROID_OEM_DATA_ARRAY(n, s) u64 android_oem_data##n[s]
#define ANDROID_BACKPORT_RESERVED(n) _ANDROID_BACKPORT_RESERVED(n)
#define android_init_vendor_data(p, n) \
memset(&p->android_vendor_data##n, 0, sizeof(p->android_vendor_data##n))
@ -42,9 +54,35 @@
#define ANDROID_VENDOR_DATA_ARRAY(n, s)
#define ANDROID_OEM_DATA(n)
#define ANDROID_OEM_DATA_ARRAY(n, s)
#define ANDROID_BACKPORT_RESERVED(n)
#define android_init_vendor_data(p, n)
#define android_init_oem_data(p, n)
#endif
/*
* Macros to use _after_ the ABI is frozen
*/
/*
* ANDROID_BACKPORT_RESERVED_USE(number, _new)
* Use a previous padding entry that was defined with
* ANDROID_BACKPORT_RESERVED
* number: the previous "number" of the padding variable
* _new: the variable to use now instead of the padding variable
*/
#define ANDROID_BACKPORT_RESERVED_USE(number, _new) \
_ANDROID_KABI_REPLACE(_ANDROID_BACKPORT_RESERVED(number), _new)
/*
* ANDROID_BACKPORT_RESERVED_USE2(number, _new1, _new2)
* Use a previous padding entry that was defined with
* ANDROID_BACKPORT_RESERVED for two new variables that fit into 64 bits.
* This is good for when you do not want to "burn" a 64bit padding variable
* for a smaller variable size if not needed.
*/
#define ANDROID_BACKPORT_RESERVED_USE2(number, _new1, _new2) \
_ANDROID_KABI_REPLACE(_ANDROID_BACKPORT_RESERVED(number), struct{ _new1; _new2; })
#endif /* _ANDROID_VENDOR_H */