diff --git a/linux-5.10/ls3a5000_patch/hdf.patch b/linux-5.10/ls3a5000_patch/hdf.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f2c0e2b77cf6433e4e2a92f7c35d953b16f2f51 --- /dev/null +++ b/linux-5.10/ls3a5000_patch/hdf.patch @@ -0,0 +1,468 @@ +diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S +index 30c102978..1d8b8de34 100644 +--- a/arch/loongarch/kernel/vmlinux.lds.S 2024-05-26 23:41:01.789696998 +0800 ++++ b/arch/loongarch/kernel/vmlinux.lds.S 2024-07-03 16:28:12.873041163 +0800 +@@ -81,6 +81,14 @@ + + . = ALIGN(4); + ++#ifdef CONFIG_DRIVERS_HDF ++ .init.hdf_table : { ++ _hdf_drivers_start = .; ++ *(.hdf.driver) ++ _hdf_drivers_end = .; ++ } ++#endif ++ + /* .exit.text is discarded at runtime, not link time, to deal with + * references from .rodata + */ +diff --git a/drivers/Kconfig b/drivers/Kconfig +index 826b2b19d..9a887e91b 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -236,6 +236,8 @@ source "drivers/interconnect/Kconfig" + + source "drivers/counter/Kconfig" + ++source "drivers/hdf/khdf/Kconfig" ++ + source "drivers/most/Kconfig" + + source "drivers/accesstokenid/Kconfig" +diff --git a/drivers/Makefile b/drivers/Makefile +index ecc494918..79507aef0 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -191,5 +191,6 @@ obj-$(CONFIG_SIOX) += siox/ + obj-$(CONFIG_GNSS) += gnss/ + obj-$(CONFIG_INTERCONNECT) += interconnect/ + obj-$(CONFIG_COUNTER) += counter/ ++obj-$(CONFIG_DRIVERS_HDF) += hdf/ + obj-$(CONFIG_MOST) += most/ + obj-$(CONFIG_ACCESS_TOKENID) += accesstokenid/ +diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile +new file mode 100644 +index 000000000..5c5e1911c +--- /dev/null ++++ b/drivers/hdf/Makefile +@@ -0,0 +1,2 @@ ++export PROJECT_ROOT := ../../../../../ ++obj-$(CONFIG_DRIVERS_HDF) += khdf/ +diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile +index 4acb583c9..ddcaf4cdc 100644 +--- a/drivers/hid/Makefile ++++ b/drivers/hid/Makefile +@@ -2,6 +2,19 @@ + # + # Makefile for the HID driver + # ++HDF_ROOT_DIR = -I$(srctree)/drivers/hdf ++ccflags-$(CONFIG_DRIVERS_HDF_INPUT) += $(HDF_ROOT_DIR)/framework/model/input/driver \ ++ $(HDF_ROOT_DIR)/framework/include/core \ ++ $(HDF_ROOT_DIR)/framework/core/common/include/host \ ++ $(HDF_ROOT_DIR)/framework/include/utils \ ++ $(HDF_ROOT_DIR)/framework/include/osal \ ++ $(HDF_ROOT_DIR)/framework/ability/sbuf/include \ ++ $(HDF_ROOT_DIR)/inner_api/utils \ ++ $(HDF_ROOT_DIR)/inner_api/osal/shared \ ++ $(HDF_ROOT_DIR)/inner_api/host/shared \ ++ $(HDF_ROOT_DIR)/inner_api/core \ ++ $(HDF_ROOT_DIR)/khdf/osal/include \ ++ $(HDF_ROOT_DIR)/evdev + hid-y := hid-core.o hid-input.o hid-quirks.o + hid-$(CONFIG_DEBUG_FS) += hid-debug.o + +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c +index 5550c943f..f0503e232 100644 +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -33,6 +33,9 @@ + #include + #include + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++#include "hdf_hid_adapter.h" ++#endif + #include "hid-ids.h" + + /* +@@ -1522,6 +1525,11 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, + hidinput_hid_event(hid, field, usage, value); + if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) + hid->hiddev_hid_event(hid, field, usage, value); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hid->input_dev) { ++ HidReportEvent(hid->input_dev, usage->type, usage->code, value); ++ } ++#endif + } + + /* +@@ -1928,6 +1936,85 @@ static const struct device_attribute dev_attr_country = { + .show = show_country, + }; + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++static bool check_mouse(char *name) ++{ ++ int i; ++ static char *option[]={"Mouse", "mouse", "MOUSE", "Razer"}; ++ for (i = 0; i < 4; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static bool check_kbd(char *name) ++{ ++ int i; ++ static char *option[]={"Keyboard", "keyboard"}; ++ for (i = 0; i < 2; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static bool check_rocker(char *name) ++{ ++ int i; ++ static char *option[]={"Thrustmaster"}; ++ for (i = 0; i < 1; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static bool check_encoder(char *name) ++{ ++ if (strcmp(name, "Wired KeyBoard") == 0) { ++ return true; ++ } ++ return false; ++} ++static bool check_trackball(char *name) ++{ ++ int i; ++ static char *option[]={"Trackball"}; ++ for (i = 0; i < 1; i++) { ++ if (strstr(name, option[i])) ++ return true; ++ } ++ return false; ++} ++static void notify_connect_event(struct hid_device *hdev) ++{ ++ bool check; ++ int type = -1; ++ HidInfo *dev = (HidInfo *)kmalloc(sizeof(HidInfo), GFP_KERNEL); ++ if (dev == NULL) { ++ printk("%s: malloc failed", __func__); ++ return; ++ } ++ type = check_mouse(hdev->name)?HID_TYPE_MOUSE:type; ++ type = check_kbd(hdev->name)?HID_TYPE_KEYBOARD:type; ++ type = check_rocker(hdev->name)?HID_TYPE_ROCKER:type; ++ type = check_encoder(hdev->name)?HID_TYPE_ENCODER:type; ++ type = check_trackball(hdev->name)?HID_TYPE_TRACKBALL:type; ++ if ( type < 0) { ++ kfree(dev); ++ dev = NULL; ++ return; ++ } ++ ++ dev->devType = type; ++ dev->devName = hdev->name; ++ hdev->input_dev = HidRegisterHdfInputDev(dev); ++ if (hdev->input_dev == NULL) { ++ printk("%s: RegisterInputDevice failed\n", __func__); ++ } ++ kfree(dev); ++ dev = NULL; ++} ++#endif ++ + int hid_connect(struct hid_device *hdev, unsigned int connect_mask) + { + static const char *types[] = { "Device", "Pointer", "Mouse", "Device", +@@ -2020,6 +2107,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) + hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", + buf, bus, hdev->version >> 8, hdev->version & 0xff, + type, hdev->name, hdev->phys); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ notify_connect_event(hdev); ++#endif + + return 0; + } +@@ -2035,6 +2125,10 @@ void hid_disconnect(struct hid_device *hdev) + if (hdev->claimed & HID_CLAIMED_HIDRAW) + hidraw_disconnect(hdev); + hdev->claimed = 0; ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hdev->input_dev) ++ HidUnregisterHdfInputDev(hdev->input_dev); ++#endif + } + EXPORT_SYMBOL_GPL(hid_disconnect); + +@@ -2119,6 +2213,11 @@ EXPORT_SYMBOL_GPL(hid_hw_open); + */ + void hid_hw_close(struct hid_device *hdev) + { ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hdev->input_dev) { ++ return; ++ } ++#endif + mutex_lock(&hdev->ll_open_lock); + if (!--hdev->ll_open_count) + hdev->ll_driver->close(hdev); +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 580d37834..fb945f4ce 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -20,6 +20,10 @@ + #include + #include + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++#include "hdf_hid_adapter.h" ++#endif ++ + #include "hid-ids.h" + + #define unk KEY_UNKNOWN +@@ -1416,7 +1420,15 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) + return; + + list_for_each_entry(hidinput, &hid->inputs, list) ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ { ++#endif + input_sync(hidinput->input); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if(hid->input_dev) ++ HidReportEvent(hid->input_dev, EV_SYN, SYN_REPORT, 0); ++ } ++#endif + } + EXPORT_SYMBOL_GPL(hidinput_report_event); + +@@ -1867,6 +1879,42 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, + report->field[i]->usage + j); + } + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++static void transfer_info(struct input_dev *dev) ++{ ++ int i; ++ HidInfo *info = (HidInfo *)kmalloc(sizeof(HidInfo),GFP_KERNEL); ++ if (info == NULL) { ++ printk("%s: malloc failed\n",__func__); ++ return; ++ } ++ info->devName = dev->name; ++ memcpy(info->devProp, dev->propbit, sizeof(unsigned long) * BITS_TO_LONGS(INPUT_PROP_CNT)); ++ memcpy(info->eventType, dev->evbit, sizeof(unsigned long) * BITS_TO_LONGS(EV_CNT)); ++ memcpy(info->keyCode, dev->keybit, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT)); ++ memcpy(info->relCode, dev->relbit, sizeof(unsigned long) * BITS_TO_LONGS(REL_CNT)); ++ memcpy(info->absCode, dev->absbit, sizeof(unsigned long) * BITS_TO_LONGS(ABS_CNT)); ++ memcpy(info->miscCode, dev->mscbit, sizeof(unsigned long) * BITS_TO_LONGS(MSC_CNT)); ++ memcpy(info->ledCode, dev->ledbit, sizeof(unsigned long) * BITS_TO_LONGS(LED_CNT)); ++ memcpy(info->soundCode, dev->sndbit, sizeof(unsigned long) * BITS_TO_LONGS(SND_CNT)); ++ memcpy(info->forceCode, dev->ffbit, sizeof(unsigned long) * BITS_TO_LONGS(FF_CNT)); ++ memcpy(info->switchCode, dev->swbit, sizeof(unsigned long) * BITS_TO_LONGS(SW_CNT)); ++ for (i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) { ++ if (dev->absbit[i] != 0) { ++ memcpy(info->axisInfo, dev->absinfo, sizeof(struct input_absinfo) * ABS_CNT); ++ break; ++ } ++ } ++ info->bustype = dev->id.bustype; ++ info->vendor = dev->id.vendor; ++ info->product = dev->id.product; ++ info->version = dev->id.version; ++ SendInfoToHdf(info); ++ kfree(info); ++ info = NULL; ++} ++#endif ++ + /* + * Register the input device; print a message. + * Configure the input layer interface +@@ -1952,6 +2000,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) + continue; + } + ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ transfer_info(hidinput->input); ++#endif + if (input_register_device(hidinput->input)) + goto out_unwind; + hidinput->registered = true; +diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile +index a48e5f2d8..90d25f224 100644 +--- a/drivers/input/misc/Makefile ++++ b/drivers/input/misc/Makefile +@@ -85,3 +85,21 @@ obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o + obj-$(CONFIG_INPUT_YEALINK) += yealink.o + obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o + ++ccflags-y +=-I$(srctree)/drivers/hdf/framework/model/input/driver \ ++ -I$(srctree)/drivers/hdf/framework/model/input/driver/input_bus_ops \ ++ -I$(srctree)/drivers/hdf/framework/include/core \ ++ -I$(srctree)/drivers/hdf/framework/core/common/include/host \ ++ -I$(srctree)/drivers/hdf/framework/include/utils \ ++ -I$(srctree)/drivers/hdf/framework/include/osal \ ++ -I$(srctree)/drivers/hdf/framework/include/platform \ ++ -I$(srctree)/drivers/hdf/framework/include/config \ ++ -I$(srctree)/drivers/hdf/framework/core/host/include \ ++ -I$(srctree)/drivers/hdf/framework/core/shared/include \ ++ -I$(srctree)/drivers/hdf/framework/utils/include \ ++ -I$(srctree)/drivers/hdf/inner_api/osal/shared \ ++ -I$(srctree)/drivers/hdf/inner_api/host/shared \ ++ -I$(srctree)/drivers/hdf/inner_api/utils \ ++ -I$(srctree)/drivers/hdf/inner_api/core \ ++ -I$(srctree)/drivers/hdf/khdf/osal/include ++ccflags-y +=-I$(srctree)/bounds_checking_function/include \ ++ -I$(srctree)/drivers/hdf/evdev +diff --git a/drivers/input/misc/rk805-pwrkey.c b/drivers/input/misc/rk805-pwrkey.c +index 3fb64dbda..394cd5912 100644 +--- a/drivers/input/misc/rk805-pwrkey.c ++++ b/drivers/input/misc/rk805-pwrkey.c +@@ -14,6 +14,9 @@ + #include + #include + #include ++#include "hdf_hid_adapter.h" ++ ++InputDevice *HidinputDev=NULL; + + static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr) + { +@@ -22,6 +25,8 @@ static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr) + input_report_key(pwr, KEY_POWER, 1); + input_sync(pwr); + ++ HidReportEvent(HidinputDev, EV_KEY, KEY_POWER, 1); ++ HidReportEvent(HidinputDev, EV_SYN, SYN_REPORT, 0); + return IRQ_HANDLED; + } + +@@ -32,9 +37,24 @@ static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr) + input_report_key(pwr, KEY_POWER, 0); + input_sync(pwr); + ++ HidReportEvent(HidinputDev, EV_KEY, KEY_POWER, 0); ++ HidReportEvent(HidinputDev, EV_SYN, SYN_REPORT, 0); + return IRQ_HANDLED; + } + ++static InputDevice* HidRegisterHdfPowerKeyDev(void) ++{ ++ InputDevice* inputDev = NULL; ++ HidInfo Hid_keyInfo; ++ ++ Hid_keyInfo.devType = HID_TYPE_KEY; ++ Hid_keyInfo.eventType[0] = SET_BIT(EV_KEY); ++ Hid_keyInfo.keyCode[3] = SET_BIT(KEY_POWER); ++ Hid_keyInfo.devName = "hid-powerkey"; ++ inputDev = HidRegisterHdfInputDev(&Hid_keyInfo); ++ return inputDev; ++} ++ + static int rk805_pwrkey_probe(struct platform_device *pdev) + { + struct input_dev *pwr; +@@ -87,6 +107,11 @@ static int rk805_pwrkey_probe(struct platform_device *pdev) + platform_set_drvdata(pdev, pwr); + device_init_wakeup(&pdev->dev, true); + ++ HidinputDev = HidRegisterHdfPowerKeyDev(); ++ if (NULL == HidinputDev) { ++ pr_err("HidRegisterHdfInputDev error\n"); ++ return -EINVAL; ++ } + return 0; + } + +diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c +index 505c562a5..67d451beb 100644 +--- a/drivers/input/mousedev.c ++++ b/drivers/input/mousedev.c +@@ -869,7 +869,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev, + + if (mixdev) { + dev_set_name(&mousedev->dev, "mice"); +- ++ mousedev->open = 1; + mousedev->open_device = mixdev_open_devices; + mousedev->close_device = mixdev_close_devices; + } else { +diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c +index e61436637..8256d576c 100644 +--- a/drivers/usb/core/notify.c ++++ b/drivers/usb/core/notify.c +@@ -66,3 +66,12 @@ void usb_notify_remove_bus(struct usb_bus *ubus) + { + blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus); + } ++ ++void usb_notify_online_status(bool online) ++{ ++ if (online) { ++ blocking_notifier_call_chain(&usb_notifier_list, USB_GADGET_ADD, NULL); ++ } else { ++ blocking_notifier_call_chain(&usb_notifier_list, USB_GADGET_REMOVE, NULL); ++ } ++} +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index b75fe5680..8b236394a 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -3633,6 +3633,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, + { + switch (event->type) { + case DWC3_DEVICE_EVENT_DISCONNECT: ++ usb_notify_online_status(false); + dwc3_gadget_disconnect_interrupt(dwc); + break; + case DWC3_DEVICE_EVENT_RESET: +@@ -3640,6 +3641,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, + break; + case DWC3_DEVICE_EVENT_CONNECT_DONE: + dwc3_gadget_conndone_interrupt(dwc); ++ usb_notify_online_status(true); + break; + case DWC3_DEVICE_EVENT_WAKEUP: + dwc3_gadget_wakeup_interrupt(dwc); +diff --git a/include/linux/hid.h b/include/linux/hid.h +index 6ed2a97eb..1d1445a23 100644 +--- a/include/linux/hid.h ++++ b/include/linux/hid.h +@@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */ + struct list_head debug_list; + spinlock_t debug_list_lock; + wait_queue_head_t debug_wait; ++ void *input_dev; + }; + + #define to_hid_device(pdev) \ +diff --git a/include/linux/usb.h b/include/linux/usb.h +index d6a41841b..de3232ee5 100644 +--- a/include/linux/usb.h ++++ b/include/linux/usb.h +@@ -2019,8 +2019,11 @@ static inline int usb_translate_errors(int error_code) + #define USB_DEVICE_REMOVE 0x0002 + #define USB_BUS_ADD 0x0003 + #define USB_BUS_REMOVE 0x0004 ++#define USB_GADGET_ADD 0x0005 ++#define USB_GADGET_REMOVE 0x0006 + extern void usb_register_notify(struct notifier_block *nb); + extern void usb_unregister_notify(struct notifier_block *nb); ++extern void usb_notify_online_status(bool online); + + /* debugfs stuff */ + extern struct dentry *usb_debug_root; diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/auxvec.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/auxvec.h index 74fca55f3621e704d8b9b9e4b8572aa7b4a2b63f..eb9bf3816b51b87fa2ba1eb0e6863a3e475e745a 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/auxvec.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/auxvec.h @@ -18,6 +18,10 @@ ****************************************************************************/ #ifndef __ASM_AUXVEC_H #define __ASM_AUXVEC_H -#define AT_SYSINFO_EHDR 33 -#define AT_VECTOR_SIZE_ARCH 1 -#endif + +/* Location of VDSO image. */ +#define AT_SYSINFO_EHDR 33 + +#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */ + +#endif /* __ASM_AUXVEC_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitfield.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitfield.h new file mode 100644 index 0000000000000000000000000000000000000000..953b1c509532dea47460096f8fff9db96a07a7ff --- /dev/null +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitfield.h @@ -0,0 +1,29 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __UAPI_ASM_BITFIELD_H +#define __UAPI_ASM_BITFIELD_H + +/* + * * Damn ... bitfields depend from byteorder :-( + * */ +#define __BITFIELD_FIELD(field, more) \ + more \ + field; + +#endif /* __UAPI_ASM_BITFIELD_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h index f68cd8919d81630e192302650133c0d938467da9..e2b1ab8ce1df353b550f0977cbddb04ab3ef9d60 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h @@ -18,6 +18,9 @@ ****************************************************************************/ #ifndef __ASM_LOONGARCH_BITSPERLONG_H #define __ASM_LOONGARCH_BITSPERLONG_H + #define __BITS_PER_LONG (__SIZEOF_LONG__ * 8) + #include -#endif + +#endif /* __ASM_LOONGARCH_BITSPERLONG_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h index fa7bc4855032b67774519e46f1369aa7947409d6..57a96fe00e8ec6972c8752f0ba5c4e140a90b26b 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h @@ -16,4 +16,11 @@ *** **************************************************************************** ****************************************************************************/ -#include +#ifndef __ASM_BPF_PERF_EVENT_H__ +#define __ASM_BPF_PERF_EVENT_H__ + +#include + +typedef struct user_pt_regs bpf_user_pt_regs_t; + +#endif /* __ASM_BPF_PERF_EVENT_H__ */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/break.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/break.h index 74860d3b0f7594779ac197dfa63155a1b164290d..e3330fbf6624e55a9d86ee791bb5a082e3f27026 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/break.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/break.h @@ -18,18 +18,20 @@ ****************************************************************************/ #ifndef __UAPI_ASM_BREAK_H #define __UAPI_ASM_BREAK_H -#define BRK_DEFAULT 0 -#define BRK_BUG 1 -#define BRK_KDB 2 -#define BRK_MATHEMU 3 -#define BRK_USERBP 4 -#define BRK_SSTEPBP 5 -#define BRK_OVERFLOW 6 -#define BRK_DIVZERO 7 -#define BRK_RANGE 8 -#define BRK_MULOVFL 9 -#define BRK_KPROBE_BP 10 -#define BRK_KPROBE_SSTEPBP 11 -#define BRK_UPROBE_BP 12 -#define BRK_UPROBE_XOLBP 13 -#endif + +#define BRK_DEFAULT 0 /* Used as default */ +#define BRK_BUG 1 /* Used by BUG() */ +#define BRK_KDB 2 /* Used in KDB_ENTER() */ +#define BRK_MATHEMU 3 /* Used by FPU emulator */ +#define BRK_USERBP 4 /* User bp (used by debuggers) */ +#define BRK_SSTEPBP 5 /* User bp (used by debuggers) */ +#define BRK_OVERFLOW 6 /* Overflow check */ +#define BRK_DIVZERO 7 /* Divide by zero check */ +#define BRK_RANGE 8 /* Range error check */ +#define BRK_MULOVFL 9 /* Multiply overflow */ +#define BRK_KPROBE_BP 10 /* Kprobe break */ +#define BRK_KPROBE_SSTEPBP 11 /* Kprobe single step break */ +#define BRK_UPROBE_BP 12 /* See */ +#define BRK_UPROBE_XOLBP 13 /* See */ + +#endif /* __UAPI_ASM_BREAK_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/byteorder.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/byteorder.h index fbca5139e500dff5d62e41ed06e6f7dfe432061b..fe1378365c08d4229f0211da14882c89801dd728 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/byteorder.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/byteorder.h @@ -18,5 +18,7 @@ ****************************************************************************/ #ifndef _ASM_BYTEORDER_H #define _ASM_BYTEORDER_H + #include -#endif + +#endif /* _ASM_BYTEORDER_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/hwcap.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/hwcap.h index 81f6931bec659e776410722ad82ee26510bea55a..8929a91f41361fb86716bf98c2c662bea87c296e 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/hwcap.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/hwcap.h @@ -18,17 +18,21 @@ ****************************************************************************/ #ifndef _ASM_HWCAP_H #define _ASM_HWCAP_H -#define HWCAP_LOONGARCH_CPUCFG (1 << 0) -#define HWCAP_LOONGARCH_LAM (1 << 1) -#define HWCAP_LOONGARCH_UAL (1 << 2) -#define HWCAP_LOONGARCH_FPU (1 << 3) -#define HWCAP_LOONGARCH_LSX (1 << 4) -#define HWCAP_LOONGARCH_LASX (1 << 5) -#define HWCAP_LOONGARCH_CRC32 (1 << 6) -#define HWCAP_LOONGARCH_COMPLEX (1 << 7) -#define HWCAP_LOONGARCH_CRYPTO (1 << 8) -#define HWCAP_LOONGARCH_LVZ (1 << 9) -#define HWCAP_LOONGARCH_LBT_X86 (1 << 10) -#define HWCAP_LOONGARCH_LBT_ARM (1 << 11) -#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12) -#endif + +/* HWCAP flags */ +#define HWCAP_LOONGARCH_CPUCFG (1 << 0) +#define HWCAP_LOONGARCH_LAM (1 << 1) +#define HWCAP_LOONGARCH_UAL (1 << 2) +#define HWCAP_LOONGARCH_FPU (1 << 3) +#define HWCAP_LOONGARCH_LSX (1 << 4) +#define HWCAP_LOONGARCH_LASX (1 << 5) +#define HWCAP_LOONGARCH_CRC32 (1 << 6) +#define HWCAP_LOONGARCH_COMPLEX (1 << 7) +#define HWCAP_LOONGARCH_CRYPTO (1 << 8) +#define HWCAP_LOONGARCH_LVZ (1 << 9) +#define HWCAP_LOONGARCH_LBT_X86 (1 << 10) +#define HWCAP_LOONGARCH_LBT_ARM (1 << 11) +#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12) +#define HWCAP_LOONGARCH_PTW (1 << 13) + +#endif /* _ASM_HWCAP_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/inst.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/inst.h new file mode 100644 index 0000000000000000000000000000000000000000..c64a0061f8e6d77935c15b188f5c8bef5b3b09c2 --- /dev/null +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/inst.h @@ -0,0 +1,486 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _ASM_INST_H +#define _ASM_INST_H + +#include + +enum reg0_op { + tlbclr_op = 0x19208, gtlbclr_op=0x19208, + tlbflush_op = 0x19209, gtlbflush_op=0x19209, + tlbsrch_op = 0x1920a, gtlbsrch_op=0x1920a, + tlbrd_op = 0x1920b, gtlbrd_op=0x1920b, + tlbwr_op = 0x1920c, gtlbwr_op=0x1920c, + tlbfill_op = 0x1920d, gtlbfill_op=0x1920d, + ertn_op = 0x1920e, +}; + +enum reg0i15_op { + break_op = 0x54, dbcl_op, syscall_op, hypcall_op, + idle_op = 0xc91, dbar_op = 0x70e4, ibar_op, +}; + +enum reg0i26_op { + b_op = 0x14, bl_op, +}; + +enum reg1i20_op { + lu12iw_op = 0xa, lu32id_op, pcaddi_op, pcalau12i_op, + pcaddu12i_op, pcaddu18i_op, +}; + +enum reg1i21_op { + beqz_op = 0x10, bnez_op, bceqz_op, bcnez_op=0x12, jiscr0_op=0x12, jiscr1_op=0x12, +}; + +enum reg2_op { + gr2scr_op = 0x2, scr2gr_op, clow_op, + clzw_op, ctow_op, ctzw_op, clod_op, + clzd_op, ctod_op, ctzd_op, revb2h_op, + revb4h_op, revb2w_op, revbd_op, revh2w_op, + revhd_op, bitrev4b_op, bitrev8b_op, bitrevw_op, + bitrevd_op, extwh_op, extwb_op, rdtimelw_op, + rdtimehw_op, rdtimed_op, cpucfg_op, + iocsrrdb_op = 0x19200, iocsrrdh_op, iocsrrdw_op, iocsrrdd_op, + iocsrwrb_op, iocsrwrh_op, iocsrwrw_op, iocsrwrd_op, + movgr2fcsr_op = 0x4530, movfcsr2gr_op = 0x4532, + movgr2cf_op = 0x4536, movcf2gr_op = 0x4537, +}; + +enum reg2ui3_op { + rotrib_op = 0x261, rcrib_op = 0x281, +}; + +enum reg2ui4_op { + rotrih_op = 0x131, rcrih_op = 0x141, +}; + +enum reg2ui5_op { + slliw_op = 0x81, srliw_op = 0x89, sraiw_op = 0x91, rotriw_op = 0x99, + rcriw_op = 0xa1, +}; + +enum reg2ui6_op { + sllid_op = 0x41, srlid_op = 0x45, sraid_op = 0x49, rotrid_op = 0x4d, + rcrid_op = 0x51, +}; + +enum reg2ui12_op { + andi_op = 0xd, ori_op, xori_op, +}; + +enum reg2lsbw_op { + bstrinsw_op = 0x3, bstrpickw_op = 0x3, +}; + +enum reg2lsbd_op { + bstrinsd_op = 0x2, bstrpickd_op = 0x3, +}; + +enum reg2i8_op { + lddir_op = 0x190, ldpte_op, +}; + +enum reg2i8idx1_op { + vstelmd_op = 0x622, +}; + +enum reg2i8idx2_op { + vstelmw_op = 0x312, xvstelmd_op = 0x331, +}; + +enum reg2i8idx3_op { + vstelmh_op = 0x18a, xvstelmw_op = 0x199, +}; + +enum reg2i8idx4_op { + vstelmb_op = 0xc6, xvstelmh_op = 0xcd, +}; + +enum reg2i8idx5_op { + xvstelmb_op = 0x67, +}; + +enum reg2i9_op { + vldrepld_op = 0x602, xvldrepld_op = 0x642, +}; + +enum reg2i10_op { + vldreplw_op = 0x302, xvldreplw_op = 0x322, +}; + +enum reg2i11_op { + vldreplh_op = 0x182, xvldreplh_op = 0x192, +}; + +enum reg2i12_op { + slti_op = 0x8, sltui_op, addiw_op, addid_op, + lu52id_op, cacop_op = 0x18, xvldreplb_op = 0xca, + ldb_op = 0xa0, ldh_op, ldw_op, ldd_op, stb_op, sth_op, + stw_op, std_op, ldbu_op, ldhu_op, ldwu_op, preld_op, + flds_op, fsts_op, fldd_op, fstd_op, vld_op, vst_op, xvld_op, + xvst_op, ldlw_op = 0xb8, ldrw_op, ldld_op, ldrd_op, stlw_op, + strw_op, stld_op, strd_op, vldreplb_op = 0xc2, +}; + +enum reg2i14_op { + llw_op = 0x20, scw_op, lld_op, scd_op, ldptrw_op, stptrw_op, + ldptrd_op, stptrd_op, +}; + +enum reg2i16_op { + addu16id_op = 0x4, jirl_op = 0x13, beq_op = 0x16, bne_op, blt_op, bge_op, bltu_op, bgeu_op, +}; + +enum reg2csr_op { + csrrd_op = 0x4, csrwr_op = 0x4, csrxchg_op = 0x4, + gcsrrd_op = 0x5, gcsrwr_op = 0x5, gcsrxchg_op = 0x5, +}; + +enum reg3_op { + asrtled_op = 0x2, asrtgtd_op, + addw_op = 0x20, addd_op, subw_op, subd_op, + slt_op, sltu_op, maskeqz_op, masknez_op, + nor_op, and_op, or_op, xor_op, orn_op, + andn_op, sllw_op, srlw_op, sraw_op, slld_op, + srld_op, srad_op, rotrb_op, rotrh_op, + rotrw_op, rotrd_op, mulw_op, mulhw_op, + mulhwu_op, muld_op, mulhd_op, mulhdu_op, + mulwdw_op, mulwdwu_op, divw_op, modw_op, + divwu_op, modwu_op, divd_op, modd_op, + divdu_op, moddu_op, crcwbw_op, + crcwhw_op, crcwww_op, crcwdw_op, crccwbw_op, + crccwhw_op, crccwww_op, crccwdw_op, addu12iw_op, + addu12id_op, + adcb_op = 0x60, adch_op, adcw_op, adcd_op, + sbcb_op, sbch_op, sbcw_op, sbcd_op, + rcrb_op, rcrh_op, rcrw_op, rcrd_op, + ldxb_op = 0x7000, ldxh_op = 0x7008, ldxw_op = 0x7010, ldxd_op = 0x7018, + stxb_op = 0x7020, stxh_op = 0x7028, stxw_op = 0x7030, stxd_op = 0x7038, + ldxbu_op = 0x7040, ldxhu_op = 0x7048, ldxwu_op = 0x7050, + preldx_op = 0x7058, fldxs_op = 0x7060, fldxd_op = 0x7068, + fstxs_op = 0x7070, fstxd_op = 0x7078, vldx_op = 0x7080, + vstx_op = 0x7088, xvldx_op = 0x7090, xvstx_op = 0x7098, + amswapw_op = 0x70c0, amswapd_op, amaddw_op, amaddd_op, amandw_op, + amandd_op, amorw_op, amord_op, amxorw_op, amxord_op, ammaxw_op, + ammaxd_op, amminw_op, ammind_op, ammaxwu_op, ammaxdu_op, + amminwu_op, ammindu_op, amswap_dbw_op, amswap_dbd_op, amadd_dbw_op, + amadd_dbd_op, amand_dbw_op, amand_dbd_op, amor_dbw_op, amor_dbd_op, + amxor_dbw_op, amxor_dbd_op, ammax_dbw_op, ammax_dbd_op, ammin_dbw_op, + ammin_dbd_op, ammax_dbwu_op, ammax_dbdu_op, ammin_dbwu_op, + ammin_dbdu_op, fldgts_op = 0x70e8, fldgtd_op, + fldles_op, fldled_op, fstgts_op, fstgtd_op, fstles_op, fstled_op, + ldgtb_op, ldgth_op, ldgtw_op, ldgtd_op, ldleb_op, ldleh_op, ldlew_op, + ldled_op, stgtb_op, stgth_op, stgtw_op, stgtd_op, stleb_op, stleh_op, + stlew_op, stled_op, +}; + +enum reg3sa2_op { + alslw_op = 0x2, alslwu_op, bytepickw_op, alsld_op = 0x16, + +}; + +enum reg3sa3_op { + bytepickd_op = 0x3, +}; + +struct reg2_format { + __BITFIELD_FIELD(unsigned int opcode : 22, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))) +}; + +struct reg2ui3_format { + __BITFIELD_FIELD(unsigned int opcode : 19, + __BITFIELD_FIELD(unsigned int simmediate : 3, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2ui4_format { + __BITFIELD_FIELD(unsigned int opcode : 18, + __BITFIELD_FIELD(unsigned int simmediate : 4, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2ui5_format { + __BITFIELD_FIELD(unsigned int opcode : 17, + __BITFIELD_FIELD(unsigned int simmediate : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2ui6_format { + __BITFIELD_FIELD(unsigned int opcode : 16, + __BITFIELD_FIELD(unsigned int simmediate : 6, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2lsbw_format { + __BITFIELD_FIELD(unsigned int opcode : 11, + __BITFIELD_FIELD(unsigned int msbw : 5, + __BITFIELD_FIELD(unsigned int op : 1, + __BITFIELD_FIELD(unsigned int lsbw : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))))) +}; + +struct reg2lsbd_format { + __BITFIELD_FIELD(unsigned int opcode : 10, + __BITFIELD_FIELD(unsigned int msbd : 6, + __BITFIELD_FIELD(unsigned int lsbd : 6, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg3_format { + __BITFIELD_FIELD(unsigned int opcode : 17, + __BITFIELD_FIELD(unsigned int rk : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg3sa2_format { + __BITFIELD_FIELD(unsigned int opcode : 15, + __BITFIELD_FIELD(unsigned int simmediate : 2, + __BITFIELD_FIELD(unsigned int rk : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg3sa3_format { + __BITFIELD_FIELD(unsigned int opcode : 14, + __BITFIELD_FIELD(unsigned int simmediate : 3, + __BITFIELD_FIELD(unsigned int rk : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg3sa4_format { + __BITFIELD_FIELD(unsigned int opcode : 13, + __BITFIELD_FIELD(unsigned int simmediate : 4, + __BITFIELD_FIELD(unsigned int rk : 5, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg4_format { + __BITFIELD_FIELD(unsigned int opcode : 12, + __BITFIELD_FIELD(unsigned int fa : 5, + __BITFIELD_FIELD(unsigned int fk : 5, + __BITFIELD_FIELD(unsigned int fj : 5, + __BITFIELD_FIELD(unsigned int fd : 5, + ;))))) +}; + +struct reg2i8_format { + __BITFIELD_FIELD(unsigned int opcode : 14, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i8idx1_format { + __BITFIELD_FIELD(unsigned int opcode : 13, + __BITFIELD_FIELD(unsigned int idx : 1, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg2i8idx2_format { + __BITFIELD_FIELD(unsigned int opcode : 12, + __BITFIELD_FIELD(unsigned int idx : 2, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg2i8idx3_format { + __BITFIELD_FIELD(unsigned int opcode : 11, + __BITFIELD_FIELD(unsigned int idx : 3, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg2i8idx4_format { + __BITFIELD_FIELD(unsigned int opcode : 10, + __BITFIELD_FIELD(unsigned int idx : 4, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg2i8idx5_format { + __BITFIELD_FIELD(unsigned int opcode : 9, + __BITFIELD_FIELD(unsigned int idx : 5, + __BITFIELD_FIELD(unsigned int simmediate : 8, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))))) +}; + +struct reg2i9_format { + __BITFIELD_FIELD(unsigned int opcode : 13, + __BITFIELD_FIELD(unsigned int simmediate : 9, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i10_format { + __BITFIELD_FIELD(unsigned int opcode : 12, + __BITFIELD_FIELD(unsigned int simmediate : 10, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i11_format { + __BITFIELD_FIELD(unsigned int opcode : 11, + __BITFIELD_FIELD(unsigned int simmediate : 11, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i12_format { + __BITFIELD_FIELD(unsigned int opcode : 10, + __BITFIELD_FIELD(signed int simmediate : 12, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2ui12_format { + __BITFIELD_FIELD(unsigned int opcode : 10, + __BITFIELD_FIELD(unsigned int simmediate : 12, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i14_format { + __BITFIELD_FIELD(unsigned int opcode : 8, + __BITFIELD_FIELD(unsigned int simmediate : 14, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2i16_format { + __BITFIELD_FIELD(unsigned int opcode : 6, + __BITFIELD_FIELD(unsigned int simmediate : 16, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg2csr_format { + __BITFIELD_FIELD(unsigned int opcode : 8, + __BITFIELD_FIELD(unsigned int csr : 14, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int rd : 5, + ;)))) +}; + +struct reg1i21_format { + __BITFIELD_FIELD(unsigned int opcode : 6, + __BITFIELD_FIELD(unsigned int simmediate_l : 16, + __BITFIELD_FIELD(unsigned int rj : 5, + __BITFIELD_FIELD(unsigned int simmediate_h : 5, + ;)))) +}; + +struct reg1i20_format { + __BITFIELD_FIELD(unsigned int opcode : 7, + __BITFIELD_FIELD(unsigned int simmediate : 20, + __BITFIELD_FIELD(unsigned int rd : 5, + ;))) +}; + +struct reg0i15_format { + __BITFIELD_FIELD(unsigned int opcode : 17, + __BITFIELD_FIELD(unsigned int simmediate : 15, + ;)) +}; + +struct reg0i26_format { + __BITFIELD_FIELD(unsigned int opcode : 6, + __BITFIELD_FIELD(unsigned int simmediate_l : 16, + __BITFIELD_FIELD(unsigned int simmediate_h : 10, + ;))) +}; + +union loongarch_instruction { + unsigned int word; + unsigned short halfword[2]; + unsigned char byte[4]; + struct reg2_format reg2_format; + struct reg2ui3_format reg2ui3_format; + struct reg2ui4_format reg2ui4_format; + struct reg2ui5_format reg2ui5_format; + struct reg2ui6_format reg2ui6_format; + struct reg2ui12_format reg2ui12_format; + struct reg2lsbw_format reg2lsbw_format; + struct reg2lsbd_format reg2lsbd_format; + struct reg3_format reg3_format; + struct reg3sa2_format reg3sa2_format; + struct reg3sa3_format reg3sa3_format; + struct reg3sa4_format reg3sa4_format; + struct reg4_format reg4_format; + struct reg2i8_format reg2i8_format; + struct reg2i8idx1_format reg2i8idx1_format; + struct reg2i8idx2_format reg2i8idx2_format; + struct reg2i8idx3_format reg2i8idx3_format; + struct reg2i8idx4_format reg2i8idx4_format; + struct reg2i8idx5_format reg2i8idx5_format; + struct reg2i9_format reg2i9_format; + struct reg2i10_format reg2i10_format; + struct reg2i11_format reg2i11_format; + struct reg2i12_format reg2i12_format; + struct reg2i14_format reg2i14_format; + struct reg2i16_format reg2i16_format; + struct reg2csr_format reg2csr_format; + struct reg1i21_format reg1i21_format; + struct reg1i20_format reg1i20_format; + struct reg0i15_format reg0i15_format; + struct reg0i26_format reg0i26_format; +}; + +#endif /* _ASM_INST_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm.h index 3f67b692fd93b9232bdc87db82ec01286adf8b55..9b512f1c03706049101e83e0000a130e416fd520 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm.h @@ -16,166 +16,264 @@ *** **************************************************************************** ****************************************************************************/ + #ifndef __LINUX_KVM_LOONGARCH_H #define __LINUX_KVM_LOONGARCH_H + #include + #include + #define __KVM_HAVE_GUEST_DEBUG #define KVM_GUESTDBG_USE_SW_BP 0x00010000 #define KVM_GUESTDBG_USE_HW_BP 0x00020000 #define KVM_DATA_HW_BREAKPOINT_NUM 8 #define KVM_INST_HW_BREAKPOINT_NUM 8 + +/* + * KVM Loongarch specific structures and definitions. + * + * Some parts derived from the x86 version of this file. + */ + #define __KVM_HAVE_READONLY_MEM + #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 + +/* + * for KVM_GET_REGS and KVM_SET_REGS + */ struct kvm_regs { - __u64 gpr[32]; - __u64 pc; + /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ + __u64 gpr[32]; + __u64 pc; }; + +/* + * for KVM_GET_CPUCFG + */ struct kvm_cpucfg { - __u32 cpucfg[64]; + /* out (KVM_GET_CPUCFG) */ + __u32 cpucfg[64]; }; + +/* + * for KVM_GET_FPU and KVM_SET_FPU + */ struct kvm_fpu { - __u32 fcsr; - __u32 none; - __u64 fcc; - struct kvm_fpureg { - __u64 val64[4]; - } fpr[32]; -}; -#define KVM_REG_LOONGARCH_GP (KVM_REG_LOONGARCH | 0x00000ULL) -#define KVM_REG_LOONGARCH_CSR (KVM_REG_LOONGARCH | 0x10000ULL) -#define KVM_REG_LOONGARCH_KVM (KVM_REG_LOONGARCH | 0x20000ULL) -#define KVM_REG_LOONGARCH_FPU (KVM_REG_LOONGARCH | 0x30000ULL) -#define KVM_REG_LOONGARCH_MASK (KVM_REG_LOONGARCH | 0x30000ULL) -#define KVM_CSR_IDX_MASK (0x10000 - 1) -#define KVM_REG_LOONGARCH_COUNTER (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 3) -#define KVM_REG_LOONGARCH_VCPU_RESET (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 4) + __u32 fcsr; + __u64 fcc; /* 8x8 */ + struct kvm_fpureg { + __u64 val64[4]; //support max 256 bits + } fpr[32]; +}; + +/* + * For LOONGARCH, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various + * registers. The id field is broken down as follows: + * + * bits[63..52] - As per linux/kvm.h + * bits[51..32] - Must be zero. + * bits[31..16] - Register set. + * + * Register set = 0: GP registers from kvm_regs (see definitions below). + * Register set = 1: CSR registers. + * Register set = 2: KVM specific registers (see definitions below). + * Register set = 3: FPU / SIMD registers (see definitions below). + * Register set = 4: LBT registers (see definitions below). + * + * Other sets registers may be added in the future. Each set would + * have its own identifier in bits[31..16]. + */ + +#define KVM_REG_LOONGARCH_GP (KVM_REG_LOONGARCH | 0x00000ULL) +#define KVM_REG_LOONGARCH_CSR (KVM_REG_LOONGARCH | 0x10000ULL) +#define KVM_REG_LOONGARCH_KVM (KVM_REG_LOONGARCH | 0x20000ULL) +#define KVM_REG_LOONGARCH_FPU (KVM_REG_LOONGARCH | 0x30000ULL) +#define KVM_REG_LOONGARCH_LBT (KVM_REG_LOONGARCH | 0x40000ULL) +#define KVM_REG_LOONGARCH_MASK (KVM_REG_LOONGARCH | 0x70000ULL) +#define KVM_CSR_IDX_MASK (0x10000 - 1) + +/* + * KVM_REG_LOONGARCH_KVM - KVM specific control registers. + */ +#define KVM_REG_LOONGARCH_COUNTER (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 3) +#define KVM_REG_LOONGARCH_VCPU_RESET (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 4) + +#define KVM_REG_LBT_SCR0 (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 1) +#define KVM_REG_LBT_SCR1 (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 2) +#define KVM_REG_LBT_SCR2 (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 3) +#define KVM_REG_LBT_SCR3 (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 4) +#define KVM_REG_LBT_FLAGS (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 5) +#define KVM_REG_LBT_FTOP (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | 6) + #define __KVM_HAVE_IRQ_LINE + struct kvm_debug_exit_arch { - __u64 era; - __u32 fwps; - __u32 mwps; - __u32 exception; + __u64 era; + __u32 fwps; + __u32 mwps; + __u32 exception; }; + +/* for KVM_SET_GUEST_DEBUG */ struct hw_breakpoint { - __u64 addr; - __u64 mask; - __u32 asid; - __u32 ctrl; + __u64 addr; + __u64 mask; + __u32 asid; + __u32 ctrl; }; + struct kvm_guest_debug_arch { - struct hw_breakpoint data_breakpoint[KVM_DATA_HW_BREAKPOINT_NUM]; - struct hw_breakpoint inst_breakpoint[KVM_INST_HW_BREAKPOINT_NUM]; - int inst_bp_nums, data_bp_nums; + struct hw_breakpoint data_breakpoint[KVM_DATA_HW_BREAKPOINT_NUM]; + struct hw_breakpoint inst_breakpoint[KVM_INST_HW_BREAKPOINT_NUM]; + int inst_bp_nums, data_bp_nums; }; + +/* definition of registers in kvm_run */ struct kvm_sync_regs { }; + +/* dummy definition */ struct kvm_sregs { }; + struct kvm_iocsr_entry { - __u32 addr; - __u32 pad; - __u64 data; + __u32 addr; + __u32 pad; + __u64 data; }; + struct kvm_csr_entry { - __u32 index; - __u32 reserved; - __u64 data; + __u32 index; + __u32 reserved; + __u64 data; }; + +/* for KVM_GET_MSRS and KVM_SET_MSRS */ struct kvm_msrs { - __u32 ncsrs; - __u32 pad; - struct kvm_csr_entry entries[0]; + __u32 ncsrs; /* number of msrs in entries */ + __u32 pad; + + struct kvm_csr_entry entries[0]; }; + struct kvm_loongarch_interrupt { - __u32 cpu; - __u32 irq; -}; -#define KVM_IRQCHIP_LS7A_IOAPIC 0x0 -#define KVM_IRQCHIP_LS3A_GIPI 0x1 -#define KVM_IRQCHIP_LS3A_HT_IRQ 0x2 -#define KVM_IRQCHIP_LS3A_ROUTE 0x3 -#define KVM_IRQCHIP_LS3A_EXTIRQ 0x4 -#define KVM_IRQCHIP_LS3A_IPMASK 0x5 -#define KVM_NR_IRQCHIPS 1 -#define KVM_IRQCHIP_NUM_PINS 64 -#define KVM_MAX_CORES 256 -#define KVM_EXTIOI_IRQS (256) -#define KVM_EXTIOI_IRQS_BITMAP_SIZE (KVM_EXTIOI_IRQS / 8) -#define KVM_EXTIOI_IRQS_IPMAP_SIZE (KVM_EXTIOI_IRQS / 32) -#define KVM_EXTIOI_IRQS_PER_GROUP 32 -#define KVM_EXTIOI_IRQS_COREMAP_SIZE (KVM_EXTIOI_IRQS) -#define KVM_EXTIOI_IRQS_NODETYPE_SIZE 16 + /* in */ + __u32 cpu; + __u32 irq; +}; + +#define KVM_IRQCHIP_LS7A_IOAPIC 0x0 +#define KVM_IRQCHIP_LS3A_GIPI 0x1 +#define KVM_IRQCHIP_LS3A_HT_IRQ 0x2 +#define KVM_IRQCHIP_LS3A_ROUTE 0x3 +#define KVM_IRQCHIP_LS3A_EXTIRQ 0x4 +#define KVM_IRQCHIP_LS3A_IPMASK 0x5 +#define KVM_NR_IRQCHIPS 1 +#define KVM_IRQCHIP_NUM_PINS 64 + +#define KVM_MAX_CORES 256 +#define KVM_EXTIOI_IRQS (256) +#define KVM_EXTIOI_IRQS_BITMAP_SIZE (KVM_EXTIOI_IRQS / 8) +/* map to ipnum per 32 irqs */ +#define KVM_EXTIOI_IRQS_IPMAP_SIZE (KVM_EXTIOI_IRQS / 32) +#define KVM_EXTIOI_IRQS_PER_GROUP 32 +#define KVM_EXTIOI_IRQS_COREMAP_SIZE (KVM_EXTIOI_IRQS) +#define KVM_EXTIOI_IRQS_NODETYPE_SIZE 16 + struct ls7a_ioapic_state { - __u64 int_id; - __u64 int_mask; - __u64 htmsi_en; - __u64 intedge; - __u64 intclr; - __u64 auto_crtl0; - __u64 auto_crtl1; - __u8 route_entry[64]; - __u8 htmsi_vector[64]; - __u64 intisr_chip0; - __u64 intisr_chip1; - __u64 last_intirr; - __u64 intirr; - __u64 intisr; - __u64 int_polarity; + /* 0x000 interrupt id register */ + __u64 int_id; + /* 0x020 interrupt mask register */ + __u64 int_mask; + /* 0x040 1=msi */ + __u64 htmsi_en; + /* 0x060 edge=1 level =0 */ + __u64 intedge; + /* 0x080 for clean edge int,set 1 clean,set 0 is noused */ + __u64 intclr; + /* 0x0c0 */ + __u64 auto_crtl0; + /* 0x0e0 */ + __u64 auto_crtl1; + /* 0x100 - 0x140 */ + __u8 route_entry[64]; + /* 0x200 - 0x240 */ + __u8 htmsi_vector[64]; + /* 0x300 */ + __u64 intisr_chip0; + /* 0x320 */ + __u64 intisr_chip1; + /* edge detection */ + __u64 last_intirr; + /* 0x380 interrupt request register */ + __u64 intirr; + /* 0x3a0 interrupt service register */ + __u64 intisr; + /* 0x3e0 interrupt level polarity selection register, + * 0 for high level tirgger + */ + __u64 int_polarity; }; + struct loongarch_gipi_single { - __u32 status; - __u32 en; - __u32 set; - __u32 clear; - __u64 buf[4]; + __u32 status; + __u32 en; + __u32 set; + __u32 clear; + __u64 buf[4]; }; + struct loongarch_gipiState { - struct loongarch_gipi_single core[KVM_MAX_CORES]; + struct loongarch_gipi_single core[KVM_MAX_CORES]; }; + struct kvm_loongarch_ls3a_extirq_state { - union ext_en_r { - uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; - uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; - } ext_en_r; - union bounce_r { - uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; - uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; - } bounce_r; - union ext_isr_r { - uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; - uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; - } ext_isr_r; - union ext_core_isr_r { - uint64_t reg_u64[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; - uint32_t reg_u32[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; - uint8_t reg_u8[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE]; - } ext_core_isr_r; - union ip_map_r { - uint64_t reg_u64; - uint32_t reg_u32[KVM_EXTIOI_IRQS_IPMAP_SIZE / 4]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_IPMAP_SIZE]; - } ip_map_r; - union core_map_r { - uint64_t reg_u64[KVM_EXTIOI_IRQS_COREMAP_SIZE / 8]; - uint32_t reg_u32[KVM_EXTIOI_IRQS_COREMAP_SIZE / 4]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_COREMAP_SIZE]; - } core_map_r; - union node_type_r { - uint64_t reg_u64[KVM_EXTIOI_IRQS_NODETYPE_SIZE / 4]; - uint32_t reg_u32[KVM_EXTIOI_IRQS_NODETYPE_SIZE / 2]; - uint16_t reg_u16[KVM_EXTIOI_IRQS_NODETYPE_SIZE]; - uint8_t reg_u8[KVM_EXTIOI_IRQS_NODETYPE_SIZE * 2]; - } node_type_r; + union ext_en_r { + uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; + uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; + } ext_en_r; + union bounce_r { + uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; + uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; + } bounce_r; + union ext_isr_r { + uint64_t reg_u64[KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; + uint32_t reg_u32[KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_BITMAP_SIZE]; + } ext_isr_r; + union ext_core_isr_r { + uint64_t reg_u64[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE / 8]; + uint32_t reg_u32[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE / 4]; + uint8_t reg_u8[KVM_MAX_CORES][KVM_EXTIOI_IRQS_BITMAP_SIZE]; + } ext_core_isr_r; + union ip_map_r { + uint64_t reg_u64; + uint32_t reg_u32[KVM_EXTIOI_IRQS_IPMAP_SIZE / 4]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_IPMAP_SIZE]; + } ip_map_r; + union core_map_r { + uint64_t reg_u64[KVM_EXTIOI_IRQS_COREMAP_SIZE / 8]; + uint32_t reg_u32[KVM_EXTIOI_IRQS_COREMAP_SIZE / 4]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_COREMAP_SIZE]; + } core_map_r; + union node_type_r { + uint64_t reg_u64[KVM_EXTIOI_IRQS_NODETYPE_SIZE / 4]; + uint32_t reg_u32[KVM_EXTIOI_IRQS_NODETYPE_SIZE / 2]; + uint16_t reg_u16[KVM_EXTIOI_IRQS_NODETYPE_SIZE]; + uint8_t reg_u8[KVM_EXTIOI_IRQS_NODETYPE_SIZE * 2]; + } node_type_r; }; + struct loongarch_kvm_irqchip { - __u16 chip_id; - __u16 len; - __u16 vcpu_id; - __u16 reserved; - char data[0]; + __u16 chip_id; + __u16 len; + __u16 vcpu_id; + __u16 reserved; + char data[0]; }; -#endif + +#endif /* __LINUX_KVM_LOONGARCH_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h index 1eaaeb76a3dc27a93d68c33d20af2d94a16a96f6..1277858052aac949dad335f6b6a6e6acbc57c6b3 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h @@ -18,6 +18,9 @@ ****************************************************************************/ #ifndef _ASM_LOONGARCH_KVM_PARA_H #define _ASM_LOONGARCH_KVM_PARA_H -#define KVM_LARCH_VCPU_PVTIME_CTRL 2 -#define KVM_LARCH_VCPU_PVTIME_IPA 0 -#endif + +/* Device Control API on vcpu fd */ +#define KVM_LARCH_VCPU_PVTIME_CTRL 2 +#define KVM_LARCH_VCPU_PVTIME_IPA 0 + +#endif /* _ASM_LOONGARCH_KVM_PARA_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h index 3b6bbf0eec43e097600f0ff64527afc9b7374a3f..d40bd1090348db4fcd1a8601e638584eb6877eeb 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h @@ -18,39 +18,40 @@ ****************************************************************************/ #ifndef _ASM_LOONGARCH_PERF_REGS_H #define _ASM_LOONGARCH_PERF_REGS_H + enum perf_event_loongarch_regs { - PERF_REG_LOONGARCH_PC, - PERF_REG_LOONGARCH_R1, - PERF_REG_LOONGARCH_R2, - PERF_REG_LOONGARCH_R3, - PERF_REG_LOONGARCH_R4, - PERF_REG_LOONGARCH_R5, - PERF_REG_LOONGARCH_R6, - PERF_REG_LOONGARCH_R7, - PERF_REG_LOONGARCH_R8, - PERF_REG_LOONGARCH_R9, - PERF_REG_LOONGARCH_R10, - PERF_REG_LOONGARCH_R11, - PERF_REG_LOONGARCH_R12, - PERF_REG_LOONGARCH_R13, - PERF_REG_LOONGARCH_R14, - PERF_REG_LOONGARCH_R15, - PERF_REG_LOONGARCH_R16, - PERF_REG_LOONGARCH_R17, - PERF_REG_LOONGARCH_R18, - PERF_REG_LOONGARCH_R19, - PERF_REG_LOONGARCH_R20, - PERF_REG_LOONGARCH_R21, - PERF_REG_LOONGARCH_R22, - PERF_REG_LOONGARCH_R23, - PERF_REG_LOONGARCH_R24, - PERF_REG_LOONGARCH_R25, - PERF_REG_LOONGARCH_R26, - PERF_REG_LOONGARCH_R27, - PERF_REG_LOONGARCH_R28, - PERF_REG_LOONGARCH_R29, - PERF_REG_LOONGARCH_R30, - PERF_REG_LOONGARCH_R31, - PERF_REG_LOONGARCH_MAX, + PERF_REG_LOONGARCH_PC, + PERF_REG_LOONGARCH_R1, + PERF_REG_LOONGARCH_R2, + PERF_REG_LOONGARCH_R3, + PERF_REG_LOONGARCH_R4, + PERF_REG_LOONGARCH_R5, + PERF_REG_LOONGARCH_R6, + PERF_REG_LOONGARCH_R7, + PERF_REG_LOONGARCH_R8, + PERF_REG_LOONGARCH_R9, + PERF_REG_LOONGARCH_R10, + PERF_REG_LOONGARCH_R11, + PERF_REG_LOONGARCH_R12, + PERF_REG_LOONGARCH_R13, + PERF_REG_LOONGARCH_R14, + PERF_REG_LOONGARCH_R15, + PERF_REG_LOONGARCH_R16, + PERF_REG_LOONGARCH_R17, + PERF_REG_LOONGARCH_R18, + PERF_REG_LOONGARCH_R19, + PERF_REG_LOONGARCH_R20, + PERF_REG_LOONGARCH_R21, + PERF_REG_LOONGARCH_R22, + PERF_REG_LOONGARCH_R23, + PERF_REG_LOONGARCH_R24, + PERF_REG_LOONGARCH_R25, + PERF_REG_LOONGARCH_R26, + PERF_REG_LOONGARCH_R27, + PERF_REG_LOONGARCH_R28, + PERF_REG_LOONGARCH_R29, + PERF_REG_LOONGARCH_R30, + PERF_REG_LOONGARCH_R31, + PERF_REG_LOONGARCH_MAX, }; -#endif +#endif /* _ASM_LOONGARCH_PERF_REGS_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ptrace.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ptrace.h index 5f8fe915c895788eb29955589511348644a52940..3594bd1d2eb80b18fd2b18e3fa193a5fb7d16cea 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ptrace.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ptrace.h @@ -18,33 +18,120 @@ ****************************************************************************/ #ifndef _ASM_PTRACE_H #define _ASM_PTRACE_H + #include + #include -#define GPR_BASE 0 -#define GPR_NUM 32 -#define GPR_END (GPR_BASE + GPR_NUM - 1) -#define ARG0 (GPR_END + 1) -#define PC (GPR_END + 2) -#define BADVADDR (GPR_END + 3) -#define NUM_FPU_REGS 32 + +/* + * For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs, + * 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR. + */ +#define GPR_BASE 0 +#define GPR_NUM 32 +#define GPR_END (GPR_BASE + GPR_NUM - 1) +#define ARG0 (GPR_END + 1) +#define PC (GPR_END + 2) +#define BADVADDR (GPR_END + 3) + +#define NUM_FPU_REGS 32 + struct user_pt_regs { - unsigned long regs[32]; - unsigned long orig_a0; - unsigned long csr_era; - unsigned long csr_badv; - unsigned long reserved[10]; + /* Main processor registers. */ + unsigned long regs[32]; + + /* Original syscall arg0. */ + unsigned long orig_a0; + + /* Special CSR registers. */ + unsigned long csr_era; + unsigned long csr_badv; + unsigned long reserved[10]; } __attribute__((aligned(8))); + struct user_fp_state { - uint64_t fpr[32]; - uint64_t fcc; - uint32_t fcsr; + uint64_t fpr[32]; + uint64_t fcc; + uint32_t fcsr; }; + struct user_lsx_state { - uint64_t vregs[32 * 2]; + /* 32 registers, 128 bits width per register. */ + uint64_t vregs[32*2]; }; + struct user_lasx_state { - uint64_t vregs[32 * 4]; + /* 32 registers, 256 bits width per register. */ + uint64_t vregs[32*4]; }; -#define PTRACE_SYSEMU 0x1f -#define PTRACE_SYSEMU_SINGLESTEP 0x20 -#endif + +/* + * This structure definition saves the LBT data structure, + * the data comes from the task_struct structure, format is as follows: + * regs[0]: thread.lbt.scr0 + * regs[1]: thread.lbt.scr1 + * regs[2]: thread.lbt.scr2 + * regs[3]: thread.lbt.scr3 + * regs[4]: thread.lbt.eflags + * regs[5]: thread.fpu.ftop + */ +struct user_lbt_state { + uint64_t regs[6]; +}; + +/* Read and write watchpoint registers. */ +#define NUM_WATCH_REGS 16 + +enum pt_watch_style { + pt_watch_style_la32, + pt_watch_style_la64 +}; + +struct la32_watch_regs { + uint32_t addr; + uint32_t mask; + /* irw/irwsta/irwmask I R W bits. + * bit 0 -- 1 if W bit is usable. + * bit 1 -- 1 if R bit is usable. + * bit 2 -- 1 if I bit is usable. + */ + uint8_t irw; + uint8_t irwstat; + uint8_t irwmask; +} __attribute__((aligned(8))); + +struct la64_watch_regs { + uint64_t addr; + uint64_t mask; + /* irw/irwsta/irwmask I R W bits. + * bit 0 -- 1 if W bit is usable. + * bit 1 -- 1 if R bit is usable. + * bit 2 -- 1 if I bit is usable. + */ + uint8_t irw; + uint8_t irwstat; + uint8_t irwmask; +} __attribute__((aligned(8))); + +struct pt_watch_regs { + int16_t max_valid; + int16_t num_valid; + enum pt_watch_style style; + union { + struct la32_watch_regs la32[NUM_WATCH_REGS]; + struct la64_watch_regs la64[NUM_WATCH_REGS]; + }; +}; + +#define PTRACE_SYSEMU 0x1f +#define PTRACE_SYSEMU_SINGLESTEP 0x20 +#define PTRACE_GET_WATCH_REGS 0xd0 +#define PTRACE_SET_WATCH_REGS 0xd1 + +/* Watch irw/irwmask/irwstat bit definitions */ +#define LA_WATCH_W (1 << 0) +#define LA_WATCH_R (1 << 1) +#define LA_WATCH_I (1 << 2) +#define LA_WATCH_IRW (LA_WATCH_W | LA_WATCH_R | LA_WATCH_I) + +#endif /* _ASM_PTRACE_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/reg.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/reg.h index 7238971a216193a48dd4026eb8a8a0a8227ace39..93430c4d73b260bb8eec7f616be3c228640ece8c 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/reg.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/reg.h @@ -18,45 +18,52 @@ ****************************************************************************/ #ifndef __UAPI_ASM_LOONGARCH_REG_H #define __UAPI_ASM_LOONGARCH_REG_H -#define LOONGARCH_EF_R0 0 -#define LOONGARCH_EF_R1 1 -#define LOONGARCH_EF_R2 2 -#define LOONGARCH_EF_R3 3 -#define LOONGARCH_EF_R4 4 -#define LOONGARCH_EF_R5 5 -#define LOONGARCH_EF_R6 6 -#define LOONGARCH_EF_R7 7 -#define LOONGARCH_EF_R8 8 -#define LOONGARCH_EF_R9 9 -#define LOONGARCH_EF_R10 10 -#define LOONGARCH_EF_R11 11 -#define LOONGARCH_EF_R12 12 -#define LOONGARCH_EF_R13 13 -#define LOONGARCH_EF_R14 14 -#define LOONGARCH_EF_R15 15 -#define LOONGARCH_EF_R16 16 -#define LOONGARCH_EF_R17 17 -#define LOONGARCH_EF_R18 18 -#define LOONGARCH_EF_R19 19 -#define LOONGARCH_EF_R20 20 -#define LOONGARCH_EF_R21 21 -#define LOONGARCH_EF_R22 22 -#define LOONGARCH_EF_R23 23 -#define LOONGARCH_EF_R24 24 -#define LOONGARCH_EF_R25 25 -#define LOONGARCH_EF_R26 26 -#define LOONGARCH_EF_R27 27 -#define LOONGARCH_EF_R28 28 -#define LOONGARCH_EF_R29 29 -#define LOONGARCH_EF_R30 30 -#define LOONGARCH_EF_R31 31 -#define LOONGARCH_EF_ORIG_A0 32 -#define LOONGARCH_EF_CSR_ERA 33 -#define LOONGARCH_EF_CSR_BADV 34 -#define LOONGARCH_EF_CSR_CRMD 35 -#define LOONGARCH_EF_CSR_PRMD 36 -#define LOONGARCH_EF_CSR_EUEN 37 -#define LOONGARCH_EF_CSR_ECFG 38 -#define LOONGARCH_EF_CSR_ESTAT 39 -#define LOONGARCH_EF_SIZE 320 -#endif + +#define LOONGARCH_EF_R0 0 +#define LOONGARCH_EF_R1 1 +#define LOONGARCH_EF_R2 2 +#define LOONGARCH_EF_R3 3 +#define LOONGARCH_EF_R4 4 +#define LOONGARCH_EF_R5 5 +#define LOONGARCH_EF_R6 6 +#define LOONGARCH_EF_R7 7 +#define LOONGARCH_EF_R8 8 +#define LOONGARCH_EF_R9 9 +#define LOONGARCH_EF_R10 10 +#define LOONGARCH_EF_R11 11 +#define LOONGARCH_EF_R12 12 +#define LOONGARCH_EF_R13 13 +#define LOONGARCH_EF_R14 14 +#define LOONGARCH_EF_R15 15 +#define LOONGARCH_EF_R16 16 +#define LOONGARCH_EF_R17 17 +#define LOONGARCH_EF_R18 18 +#define LOONGARCH_EF_R19 19 +#define LOONGARCH_EF_R20 20 +#define LOONGARCH_EF_R21 21 +#define LOONGARCH_EF_R22 22 +#define LOONGARCH_EF_R23 23 +#define LOONGARCH_EF_R24 24 +#define LOONGARCH_EF_R25 25 +#define LOONGARCH_EF_R26 26 +#define LOONGARCH_EF_R27 27 +#define LOONGARCH_EF_R28 28 +#define LOONGARCH_EF_R29 29 +#define LOONGARCH_EF_R30 30 +#define LOONGARCH_EF_R31 31 + +/* + * Saved special registers + */ +#define LOONGARCH_EF_ORIG_A0 32 +#define LOONGARCH_EF_CSR_ERA 33 +#define LOONGARCH_EF_CSR_BADV 34 +#define LOONGARCH_EF_CSR_CRMD 35 +#define LOONGARCH_EF_CSR_PRMD 36 +#define LOONGARCH_EF_CSR_EUEN 37 +#define LOONGARCH_EF_CSR_ECFG 38 +#define LOONGARCH_EF_CSR_ESTAT 39 + +#define LOONGARCH_EF_SIZE 320 /* size in bytes */ + +#endif /* __UAPI_ASM_LOONGARCH_REG_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h index 18efcb3e15defc1c1a6962abbebb9ec8f1d90c9f..dd35d8fb13c5bfc0f98c14522cf2aeed5227d221 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h @@ -18,42 +18,64 @@ ****************************************************************************/ #ifndef _ASM_SIGCONTEXT_H #define _ASM_SIGCONTEXT_H + #include #include -#define SC_USED_FP (1 << 0) -#define SC_ADDRERR_RD (1 << 30) -#define SC_ADDRERR_WR (1 << 31) + +/* FP context was used */ +#define SC_USED_FP (1 << 0) +/* Address error was due to memory load */ +#define SC_ADDRERR_RD (1 << 30) +/* Address error was due to memory store */ +#define SC_ADDRERR_WR (1 << 31) + struct sigcontext { - __u64 sc_pc; - __u64 sc_regs[32]; - __u32 sc_flags; - __u64 sc_extcontext[0] __attribute__((__aligned__(16))); + __u64 sc_pc; + __u64 sc_regs[32]; + __u32 sc_flags; + __u64 sc_extcontext[0] __attribute__((__aligned__(16))); }; -#define CONTEXT_INFO_ALIGN 16 + +#define CONTEXT_INFO_ALIGN 16 struct sctx_info { - __u32 magic; - __u32 size; - __u64 padding; + __u32 magic; + __u32 size; + __u64 padding; /* padding to 16 bytes */ }; -#define FPU_CTX_MAGIC 0x46505501 -#define FPU_CTX_ALIGN 8 + +/* FPU context */ +#define FPU_CTX_MAGIC 0x46505501 +#define FPU_CTX_ALIGN 8 struct fpu_context { - __u64 regs[32]; - __u64 fcc; - __u32 fcsr; + __u64 regs[32]; + __u64 fcc; + __u32 fcsr; }; -#define LSX_CTX_MAGIC 0x53580001 -#define LSX_CTX_ALIGN 16 + +/* LSX context */ +#define LSX_CTX_MAGIC 0x53580001 +#define LSX_CTX_ALIGN 16 struct lsx_context { - __u64 regs[2 * 32]; - __u64 fcc; - __u32 fcsr; + __u64 regs[2*32]; + __u64 fcc; + __u32 fcsr; }; -#define LASX_CTX_MAGIC 0x41535801 -#define LASX_CTX_ALIGN 32 + +/* LASX context */ +#define LASX_CTX_MAGIC 0x41535801 +#define LASX_CTX_ALIGN 32 struct lasx_context { - __u64 regs[4 * 32]; - __u64 fcc; - __u32 fcsr; + __u64 regs[4*32]; + __u64 fcc; + __u32 fcsr; }; -#endif + +/* LBT context */ +#define LBT_CTX_MAGIC 0x42540001 +#define LBT_CTX_ALIGN 8 +struct lbt_context { + __u64 scr[4]; + __u32 eflags; +}; + +#endif /* _ASM_SIGCONTEXT_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/signal.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/signal.h index 3a8f1217307d8da36cbb11f8112b5cf9121de3c5..9b6241464d03e9779859b88413e24b7284a4ec28 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/signal.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/signal.h @@ -18,7 +18,10 @@ ****************************************************************************/ #ifndef _ASM_SIGNAL_H #define _ASM_SIGNAL_H + #define MINSIGSTKSZ 4096 -#define SIGSTKSZ 16384 +#define SIGSTKSZ 16384 + #include + #endif diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/swab.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/swab.h index 0049f5340d746b77fbced1258debd123c2ae007b..2870183788d5a7a7fb3aa6436ff17c74ac152903 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/swab.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/swab.h @@ -16,4 +16,48 @@ *** **************************************************************************** ****************************************************************************/ -#include +#ifndef _ASM_SWAB_H +#define _ASM_SWAB_H + + +#include + +#define __SWAB_64_THRU_32__ + +static __inline__ __u16 __arch_swab16(__u16 x) +{ + __asm__( + " revb.2h %0, %1 \n" + : "=r" (x) + : "r" (x)); + + return x; +} +#define __arch_swab16 __arch_swab16 + +static __inline__ __u32 __arch_swab32(__u32 x) +{ + __asm__( + " revb.2h %0, %1 \n" + " rotri.w %0, %0, 16 \n" + : "=r" (x) + : "r" (x)); + + return x; +} +#define __arch_swab32 __arch_swab32 + +#ifdef __loongarch64 +static __inline__ __u64 __arch_swab64(__u64 x) +{ + __asm__( + " revb.4h %0, %1 \n" + " revh.d %0, %0 \n" + : "=r" (x) + : "r" (x)); + + return x; +} +#define __arch_swab64 __arch_swab64 +#endif /* __loongarch64 */ +#endif /* _ASM_SWAB_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ucontext.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ucontext.h index 6b3345bd4d277d674387dc63a3a2bac80d34daf4..bb09972c82c98ca50aef60760985e6dfbd8bd6d9 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ucontext.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/ucontext.h @@ -18,12 +18,35 @@ ****************************************************************************/ #ifndef __LOONGARCH_UAPI_ASM_UCONTEXT_H #define __LOONGARCH_UAPI_ASM_UCONTEXT_H + +/** + * struct ucontext - user context structure + * @uc_flags: + * @uc_link: + * @uc_stack: + * @uc_mcontext: holds basic processor state + * @uc_sigmask: + * @uc_extcontext: holds extended processor state + */ struct ucontext { - unsigned long uc_flags; - struct ucontext * uc_link; - stack_t uc_stack; - sigset_t uc_sigmask; - __u8 __linux_unused[1024 / 8 - sizeof(sigset_t)]; - struct sigcontext uc_mcontext; + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + sigset_t uc_sigmask; + /* There's some padding here to allow sigset_t to be expanded in the + * future. Though this is unlikely, other architectures put uc_sigmask + * at the end of this structure and explicitly state it can be + * expanded, so we didn't want to box ourselves in here. */ + __u8 __unused[1024 / 8 - sizeof(sigset_t)]; + /* We can't put uc_sigmask at the end of this structure because we need + * to be able to expand sigcontext in the future. For example, the + * vector ISA extension will almost certainly add ISA state. We want + * to ensure all user-visible ISA state can be saved and restored via a + * ucontext, so we're putting this at the end in order to allow for + * infinite extensibility. Since we know this will be extended and we + * assume sigset_t won't be extended an extreme amount, we're + * prioritizing this. */ + struct sigcontext uc_mcontext; }; -#endif + +#endif /* __LOONGARCH_UAPI_ASM_UCONTEXT_H */ diff --git a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/unistd.h b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/unistd.h index 9ff4d08e735fb7b5abb0769c31a2d4a015734d86..f4267834216e4f35d661f8d9273af479058eb89d 100644 --- a/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/unistd.h +++ b/linux-5.10/prebuilts/usr/include/asm-loongarch/asm/unistd.h @@ -18,4 +18,5 @@ ****************************************************************************/ #define __ARCH_WANT_SYS_CLONE #define __ARCH_WANT_SYS_CLONE3 + #include diff --git a/linux-5.10/prebuilts/usr/include/linux/audit.h b/linux-5.10/prebuilts/usr/include/linux/audit.h index 2c18e0795b1276f071f5c72e7af83b6b40cc8709..78059e2cf9bfa4c76a0fc453b6ea0f099c3a7d5f 100644 --- a/linux-5.10/prebuilts/usr/include/linux/audit.h +++ b/linux-5.10/prebuilts/usr/include/linux/audit.h @@ -318,6 +318,8 @@ enum { #define AUDIT_ARCH_UNICORE (EM_UNICORE | __AUDIT_ARCH_LE) #define AUDIT_ARCH_X86_64 (EM_X86_64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) #define AUDIT_ARCH_XTENSA (EM_XTENSA) +#define AUDIT_ARCH_LOONGARCH32 (EM_LOONGARCH|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #define AUDIT_PERM_EXEC 1 #define AUDIT_PERM_WRITE 2 #define AUDIT_PERM_READ 4 diff --git a/linux-5.10/prebuilts/usr/include/linux/elf-em.h b/linux-5.10/prebuilts/usr/include/linux/elf-em.h index d1ed1f6ce063eb0e2872436d932361afac6f222d..18ea87150fa77c9ad22216e7743896c625b6b779 100644 --- a/linux-5.10/prebuilts/usr/include/linux/elf-em.h +++ b/linux-5.10/prebuilts/usr/include/linux/elf-em.h @@ -61,6 +61,7 @@ #define EM_RISCV 243 #define EM_BPF 247 #define EM_CSKY 252 +#define EM_LOONGARCH 258 /* LoongArch */ #define EM_FRV 0x5441 #define EM_ALPHA 0x9026 #define EM_CYGNUS_M32R 0x9041