Re: [PATCH] arm64: Add purgatory printing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Matthias,

On 9/17/20 12:38 PM, matthias.bgg@xxxxxxxxxx wrote:
Add option to allow purgatory printing on arm64 hardware
> by passing the console name which should be used.

> +static uint64_t find_purgatory_sink(const char *console)
> +{
> +	int fd, ret;
> +	char folder[255], device[255], mem[255];
> +	struct stat sb;
> +	char buffer[18];
> +	uint64_t iomem = 0x0;
> +
> +	if (!console)
> +		return 0;
> +
> +	sprintf(device, "/sys/class/tty/%s", console);
> +	if (!stat(folder, &sb) == 0 && S_ISDIR(sb.st_mode)) {
> +		fprintf(stderr, "kexec: %s: No valid console found for %s\n",
> +			__func__, device);
> +		return 0;
> +	}
> +
> +	sprintf(mem, "%s%s", device, "/iomem_base");
> +	printf("console memory read from %s\n", mem);
> +
> +	fd = open(mem, O_RDONLY);
> +	if (fd < 0) {
> +		fprintf(stderr, "kexec: %s: No able to open %s\n",
> +			__func__, mem);
> +		return 0;
> +	}
> +
> +	memset(buffer, '\0', sizeof(char) * 18);

I think I'd like to just see 'memset(buffer, 0, sizeof(buffer));'.

> +	ret = read(fd, buffer, 18);

And 'ret = read(fd, buffer, sizeof(buffer));'.

> +	if (ret < 0) {
> +		fprintf(stderr, "kexec: %s: not able to read fd\n", __func__);
> +		close(fd);
> +		return 0;
> +	}
> +
> +	sscanf(buffer, "%lx", &iomem);
> +	printf("console memory is at %#lx\n", iomem);
> +
> +	close(fd);
> +	return iomem;
> +}
> +

Otherwise, looks OK.

-Geoff

_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux