代码拉取完成,页面将自动刷新
#include <linux/version.h>
#include "ext_hw_breakpoint.h"
#include "hw_breakpoint_until.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 72)
#define VM_LAZY_FREE 0x02
#define VM_VM_AREA 0x04
#endif
#ifdef HW_PROC_CMD_DEBUG
static void print_cmd_params(int argc, char *argv[])
{
int loop = 0;
for (loop = 0; loop < argc; loop++) {
pr_info("loop:%d, %s\n", loop, argv[loop]);
}
}
#endif
void process_cmd_string(char *p_buf, int *p_argc, char *p_argv[])
{
int i_argc;
char *p_tmp = p_buf;
p_argv[0] = p_buf;
i_argc = 1;
while (*p_tmp) {
if (' ' == *p_tmp) {
*p_tmp = '\0';
p_argv[i_argc++] = p_tmp + 1;
}
p_tmp++;
}
*p_argc = i_argc;
#ifdef HW_PROC_CMD_DEBUG
print_cmd_params(*pArgc, pArgv);
#endif
}
void free_iophys_info(iophys_info *info)
{
iophys_info *node = NULL, *next = NULL;
if (info) {
list_for_each_entry_safe (node, next, &info->list, list) {
list_del(&node->list);
kfree(node);
}
kfree(info);
}
}
EXPORT_SYMBOL_GPL(free_iophys_info);
iophys_info *get_iophys_info(u64 addr)
{
struct vmap_area *va = NULL;
struct vm_struct *area = NULL;
struct vm_struct *next = NULL;
iophys_info *head = NULL;
iophys_info *node = NULL;
if (!HW_SYMS_VAL(vmap_area_lock) || !HW_SYMS_VAL(vmap_area_lock)) {
pr_info("vmap_area_list or vmap_area_lock is NULL, can not get virt");
return head;
}
spin_lock(HW_SYMS_VAL(vmap_area_lock));
list_for_each_entry (va, HW_SYMS_VAL(vmap_area_list), list) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 72)
if (!(va->flags & VM_VM_AREA)) {
continue;
}
#endif
if (!va) {
continue;
}
area = va->vm;
if (!area) {
continue;
}
if (!(area->flags & VM_IOREMAP) ||
area->flags & VM_UNINITIALIZED) {
continue;
}
smp_rmb();
/*If you find the I/O address, check whether the I/O address you want to query is within the I/O address range*/
next = area;
while (next) {
if (next->phys_addr && next->size) {
/*The IO address to be queried is within its range*/
if (addr >= next->phys_addr &&
addr < next->phys_addr + next->size) {
/*find it*/
if (head == NULL) {
head = kzalloc(
sizeof(iophys_info),
GFP_KERNEL);
if (head == NULL) {
goto err;
}
INIT_LIST_HEAD(&head->list);
head->area = *next;
head->virt_addr =
(u64)next->addr + addr -
next->phys_addr;
}
node = kzalloc(sizeof(iophys_info),
GFP_KERNEL);
if (node == NULL) {
goto free;
}
INIT_LIST_HEAD(&node->list);
node->area = *next;
node->virt_addr = (u64)next->addr +
addr -
next->phys_addr;
list_add_tail(&node->list, &head->list);
}
}
next = next->next;
if (next == area) {
break;
}
}
}
spin_unlock(HW_SYMS_VAL(vmap_area_lock));
return head;
free:
free_iophys_info(head);
err:
spin_unlock(HW_SYMS_VAL(vmap_area_lock));
return NULL;
}
EXPORT_SYMBOL_GPL(get_iophys_info);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。