From ee930fffee469d076998274a2ca55e13dc1efb67 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 10 May 2024 08:50:54 +0000
Subject: [PATCH] enable tun/tap/iptables

---
 u-boot/arch/arm/mach-rockchip/vendor.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/u-boot/arch/arm/mach-rockchip/vendor.c b/u-boot/arch/arm/mach-rockchip/vendor.c
index fce520d..2a146b7 100644
--- a/u-boot/arch/arm/mach-rockchip/vendor.c
+++ b/u-boot/arch/arm/mach-rockchip/vendor.c
@@ -10,6 +10,7 @@
 #include <boot_rkimg.h>
 #include <nand.h>
 #include <part.h>
+#include <fdt_support.h>
 
 /* tag for vendor check */
 #define VENDOR_TAG		0x524B5644
@@ -20,6 +21,9 @@
 /* align to 64 bytes */
 #define VENDOR_BTYE_ALIGN	0x3F
 #define VENDOR_BLOCK_SIZE	512
+
+#define PAGE_ALGIN_SIZE		(4096uL)
+#define PAGE_ALGIN_MASK		(~(PAGE_ALGIN_SIZE - 1))
 
 /* --- Emmc define --- */
 /* Starting address of the Vendor in memory. */
@@ -493,13 +497,14 @@
 	/* Initialize */
 	bootdev_type = dev_desc->if_type;
 
-	/* Always use, no need to release */
-	buffer = (u8 *)malloc(size);
+	/* Always use, no need to release, align to page size for kerenl reserved memory */
+	buffer = (u8 *)memalign(PAGE_ALGIN_SIZE, size);
 	if (!buffer) {
 		printf("[Vendor ERROR]:Malloc failed!\n");
 		ret = -ENOMEM;
 		goto out;
 	}
+
 	/* Pointer initialization */
 	vendor_info.hdr = (struct vendor_hdr *)buffer;
 	vendor_info.item = (struct vendor_item *)(buffer + sizeof(struct vendor_hdr));
@@ -566,6 +571,29 @@
 	return ret;
 }
 
+void vendor_storage_fixup(void *blob)
+{
+	unsigned long size;
+	unsigned long start;
+	ulong offset;
+
+	/* init vendor storage */
+	if (!bootdev_type) {
+		if (vendor_storage_init() < 0)
+			return;
+	}
+
+	offset = fdt_node_offset_by_compatible(blob, 0, "rockchip,vendor-storage-rm");
+	if (offset >= 0) {
+		start = (unsigned long)vendor_info.hdr;
+		size = (unsigned long)((void *)vendor_info.version2 - (void *)vendor_info.hdr);
+		size += 4;
+		fdt_update_reserved_memory(blob, "rockchip,vendor-storage-rm",
+					   (u64)start,
+					   (u64)size);
+	}
+}
+
 /*
  * @id: item id, first 4 id is occupied:
  *	VENDOR_SN_ID

--
Gitblit v1.6.2