svn commit: r297285 - in head/sys/arm: arm include

Michal Meloun mmel at FreeBSD.org
Sat Mar 26 06:57:38 UTC 2016


Author: mmel
Date: Sat Mar 26 06:57:36 2016
New Revision: 297285
URL: https://svnweb.freebsd.org/changeset/base/297285

Log:
  ARM: Fix ATAG handling in LINUX_BOOT_API:
   - Don't convert atags address passed from U-Boot. It's real physical
     address (and we have 1:1 mapping).
   - Size of tags is encoded in words, not in bytes

Modified:
  head/sys/arm/arm/machdep.c
  head/sys/arm/include/atags.h

Modified: head/sys/arm/arm/machdep.c
==============================================================================
--- head/sys/arm/arm/machdep.c	Sat Mar 26 06:55:55 2016	(r297284)
+++ head/sys/arm/arm/machdep.c	Sat Mar 26 06:57:36 2016	(r297285)
@@ -1035,6 +1035,7 @@ linux_parse_boot_param(struct arm_boot_p
 	struct arm_lbabi_tag *walker;
 	uint32_t revision;
 	uint64_t serial;
+	int size;
 #ifdef FDT
 	struct fdt_header *dtb_ptr;
 	uint32_t dtb_size;
@@ -1061,8 +1062,7 @@ linux_parse_boot_param(struct arm_boot_p
 		return (0);
 
 	board_id = abp->abp_r1;
-	walker = (struct arm_lbabi_tag *)
-	    (abp->abp_r2 + KERNVIRTADDR - abp->abp_physaddr);
+	walker = (struct arm_lbabi_tag *)abp->abp_r2;
 
 	if (ATAG_TAG(walker) != ATAG_CORE)
 		return 0;
@@ -1079,8 +1079,9 @@ linux_parse_boot_param(struct arm_boot_p
 		case ATAG_INITRD2:
 			break;
 		case ATAG_SERIAL:
-			serial = walker->u.tag_sn.low |
-			    ((uint64_t)walker->u.tag_sn.high << 32);
+			serial = walker->u.tag_sn.high;
+			serial <<= 32;
+			serial |= walker->u.tag_sn.low;
 			board_set_serial(serial);
 			break;
 		case ATAG_REVISION:
@@ -1089,8 +1090,12 @@ linux_parse_boot_param(struct arm_boot_p
 			break;
 		case ATAG_CMDLINE:
 			/* XXX open question: Parse this for boothowto? */
-			bcopy(walker->u.tag_cmd.command, linux_command_line,
-			      ATAG_SIZE(walker));
+			size = ATAG_SIZE(walker) -
+			    sizeof(struct arm_lbabi_header);
+			size = min(size, sizeof(linux_command_line) - 1);
+			strncpy(linux_command_line, walker->u.tag_cmd.command,
+			    size);
+			linux_command_line[size] = '\0';
 			break;
 		default:
 			break;

Modified: head/sys/arm/include/atags.h
==============================================================================
--- head/sys/arm/include/atags.h	Sat Mar 26 06:55:55 2016	(r297284)
+++ head/sys/arm/include/atags.h	Sat Mar 26 06:57:36 2016	(r297285)
@@ -123,7 +123,7 @@ struct arm_lbabi_tag
 };
 
 #define	ATAG_TAG(a)  (a)->tag_hdr.tag
-#define ATAG_SIZE(a) (a)->tag_hdr.size
+#define ATAG_SIZE(a) ((a)->tag_hdr.size * sizeof(uint32_t))
 #define ATAG_NEXT(a) (struct arm_lbabi_tag *)((char *)(a) + ATAG_SIZE(a))
 
 #endif /* __MACHINE_ATAGS_H__ */


More information about the svn-src-all mailing list