diff --git a/linux-6.6/ls3a5000_patch/hdf.patch b/linux-6.6/ls3a5000_patch/hdf.patch new file mode 100644 index 0000000000000000000000000000000000000000..f46d616563d38ae9a502d9eac8da7f1603ba8dca --- /dev/null +++ b/linux-6.6/ls3a5000_patch/hdf.patch @@ -0,0 +1,496 @@ +From cebf4a22f22fd70ffaa9de73d1fa9c2656acda4c Mon Sep 17 00:00:00 2001 +From: gaojuxin +Date: Tue, 27 Aug 2024 14:37:13 +0800 +Subject: [PATCH] LoongArch: Add hdf driver support for loongarch + +Signed-off-by: gaojuxin +--- + arch/loongarch/kernel/vmlinux.lds.S | 8 +++ + drivers/Kconfig | 2 + + drivers/Makefile | 1 + + drivers/hdf/Makefile | 2 + + drivers/hid/Makefile | 13 ++++ + drivers/hid/hid-core.c | 99 +++++++++++++++++++++++++++++ + drivers/hid/hid-input.c | 51 +++++++++++++++ + drivers/input/misc/Makefile | 18 ++++++ + drivers/input/misc/rk805-pwrkey.c | 25 ++++++++ + drivers/input/mousedev.c | 2 +- + drivers/usb/core/notify.c | 9 +++ + drivers/usb/dwc3/gadget.c | 2 + + include/linux/hid.h | 1 + + include/linux/usb.h | 3 + + 14 files changed, 235 insertions(+), 1 deletion(-) + create mode 100644 drivers/hdf/Makefile + +diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S +index bb2ec86f37a8..047515b55c77 100644 +--- a/arch/loongarch/kernel/vmlinux.lds.S ++++ b/arch/loongarch/kernel/vmlinux.lds.S +@@ -84,6 +84,14 @@ SECTIONS + EXIT_DATA + } + ++#ifdef CONFIG_DRIVERS_HDF ++ .init.hdf_table : { ++ _hdf_drivers_start = .; ++ *(.hdf.driver) ++ _hdf_drivers_end = .; ++ } ++#endif ++ + #ifdef CONFIG_SMP + PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT) + #endif +diff --git a/drivers/Kconfig b/drivers/Kconfig +index 4600b6ba5446..f4ce081bb2e4 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -237,6 +237,8 @@ source "drivers/interconnect/Kconfig" + + source "drivers/counter/Kconfig" + ++source "drivers/hdf/khdf/Kconfig" ++ + source "drivers/most/Kconfig" + + source "drivers/peci/Kconfig" +diff --git a/drivers/Makefile b/drivers/Makefile +index 34963a7f5ec1..18da6bca9240 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -195,6 +195,7 @@ 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_PECI) += peci/ + obj-$(CONFIG_HTE) += hte/ +diff --git a/drivers/hdf/Makefile b/drivers/hdf/Makefile +new file mode 100644 +index 000000000000..5c5e1911c4f7 +--- /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 8a06d0f840bc..f005edd1dcc0 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 e0181218ad85..583d6aabf236 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" + + /* +@@ -1541,6 +1544,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 + } + + /* +@@ -2166,6 +2174,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", +@@ -2268,6 +2355,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; + } +@@ -2328,6 +2418,10 @@ void hid_hw_stop(struct hid_device *hdev) + { + hid_disconnect(hdev); + hdev->ll_driver->stop(hdev); ++#if defined(CONFIG_DRIVERS_HDF_INPUT) ++ if (hdev->input_dev) ++ HidUnregisterHdfInputDev(hdev->input_dev); ++#endif + } + EXPORT_SYMBOL_GPL(hid_hw_stop); + +@@ -2369,6 +2463,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 c8b20d44b147..2c302021fe8d 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 +@@ -1745,7 +1749,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); + +@@ -2267,6 +2279,42 @@ static inline void hidinput_configure_usages(struct hid_input *hidinput, + 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 +@@ -2352,6 +2400,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 04296a4abe8e..1638e872f162 100644 +--- a/drivers/input/misc/Makefile ++++ b/drivers/input/misc/Makefile +@@ -90,3 +90,21 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o + 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 76873aa005b4..4e279fe2ea63 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 505c562a5daa..67d451beba08 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 e6143663778f..8256d576c762 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 28f49400f3e8..abcc53a0779c 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -4360,6 +4360,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: +@@ -4367,6 +4368,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, event->event_info); +diff --git a/include/linux/hid.h b/include/linux/hid.h +index 3b08a2957229..12de49aa3779 100644 +--- a/include/linux/hid.h ++++ b/include/linux/hid.h +@@ -686,6 +686,7 @@ struct hid_device { /* device report descriptor */ + #ifdef CONFIG_BPF + struct hid_bpf bpf; /* hid-bpf data */ + #endif /* CONFIG_BPF */ ++ void *input_dev; + }; + + void hiddev_free(struct kref *ref); +diff --git a/include/linux/usb.h b/include/linux/usb.h +index a21074861f91..9e75513e4f7e 100644 +--- a/include/linux/usb.h ++++ b/include/linux/usb.h +@@ -2056,8 +2056,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; +-- +2.39.2 + diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/auxvec.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/auxvec.h new file mode 100644 index 0000000000000000000000000000000000000000..922d9e6b50586827343fdf4860ee3149cce68191 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/auxvec.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Author: Hanlu Li + * Huacai Chen + * + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ + +#ifndef __ASM_AUXVEC_H +#define __ASM_AUXVEC_H + +/* 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-6.6/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h new file mode 100644 index 0000000000000000000000000000000000000000..00b4ba1e5cdf032f81aff9f728dcffea68571880 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/bitsperlong.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_LOONGARCH_BITSPERLONG_H +#define __ASM_LOONGARCH_BITSPERLONG_H + +#define __BITS_PER_LONG (__SIZEOF_LONG__ * 8) + +#include + +#endif /* __ASM_LOONGARCH_BITSPERLONG_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h new file mode 100644 index 0000000000000000000000000000000000000000..fcba2e0eed37ae0e2b8b252835a2b6c82af851ac --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/bpf_perf_event.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#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-6.6/prebuilts/usr/include/asm-loongarch/asm/break.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/break.h new file mode 100644 index 0000000000000000000000000000000000000000..bb9b82ba59f2b0d285ee5377e0b8b04d279a9492 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/break.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#ifndef __UAPI_ASM_BREAK_H +#define __UAPI_ASM_BREAK_H + +#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-6.6/prebuilts/usr/include/asm-loongarch/asm/byteorder.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/byteorder.h new file mode 100644 index 0000000000000000000000000000000000000000..b1722d890debdb34c9ca79d396ddc68b44f94af0 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/byteorder.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Author: Hanlu Li + * Huacai Chen + * + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#ifndef _ASM_BYTEORDER_H +#define _ASM_BYTEORDER_H + +#include + +#endif /* _ASM_BYTEORDER_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/errno.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/errno.h new file mode 100644 index 0000000000000000000000000000000000000000..9addba5926463b5644233f6b9ab4b0a8fe492abe --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/errno.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/fcntl.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/fcntl.h new file mode 100644 index 0000000000000000000000000000000000000000..a77648c505d1784915fc69283e7448b24b471c1e --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/fcntl.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/hwcap.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/hwcap.h new file mode 100644 index 0000000000000000000000000000000000000000..d2ec25bf7176dbd23fc05d4556f834e57375c340 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/hwcap.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_HWCAP_H +#define _ASM_HWCAP_H + +/* 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-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctl.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctl.h new file mode 100644 index 0000000000000000000000000000000000000000..b809c4566e5f8b119f98aa55173938912203723d --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctl.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctls.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctls.h new file mode 100644 index 0000000000000000000000000000000000000000..9ea7e6821d75802d42364593e0ecfcfeac7d862c --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ioctls.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ipcbuf.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ipcbuf.h new file mode 100644 index 0000000000000000000000000000000000000000..90d6445a14df81c369ea5e0b04f0d48086c10a7d --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ipcbuf.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h new file mode 100644 index 0000000000000000000000000000000000000000..baacc4996d18e77e1b1e37b7a0ebcaf5f9a535e5 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/kvm_para.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/mman.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/mman.h new file mode 100644 index 0000000000000000000000000000000000000000..306fc0460b800861b885674420275436a55ca4c3 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/mman.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/msgbuf.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/msgbuf.h new file mode 100644 index 0000000000000000000000000000000000000000..208330735f798e2c994173acde72fad628e45d04 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/msgbuf.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/param.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/param.h new file mode 100644 index 0000000000000000000000000000000000000000..b4f6b92cc0f4eddda54a4381e233f12cfee3c972 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/param.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h new file mode 100644 index 0000000000000000000000000000000000000000..29d69c00fc7a665f743d931223916c43cd0b4849 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/perf_regs.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#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, +}; +#endif /* _ASM_LOONGARCH_PERF_REGS_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/poll.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/poll.h new file mode 100644 index 0000000000000000000000000000000000000000..b7132a305a476847d1b05aabc8087c89e6523c1d --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/poll.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/posix_types.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/posix_types.h new file mode 100644 index 0000000000000000000000000000000000000000..97b3f1f1e323c1c79dce5a31bedf99255a14910d --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/posix_types.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ptrace.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ptrace.h new file mode 100644 index 0000000000000000000000000000000000000000..eadc453ece03a4a723e5cf1d5c01e60faa85a9f3 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ptrace.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Author: Hanlu Li + * Huacai Chen + * + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#ifndef _ASM_PTRACE_H +#define _ASM_PTRACE_H + +#include + +#include + +/* + * 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 { + /* 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; +}; + +struct user_lsx_state { + /* 32 registers, 128 bits width per register. */ + uint64_t vregs[32*2]; +}; + +struct user_lasx_state { + /* 32 registers, 256 bits width per register. */ + uint64_t vregs[32*4]; +}; + +struct user_lbt_state { + uint64_t scr[4]; + uint32_t eflags; + uint32_t ftop; +}; + +struct user_watch_state { + uint64_t dbg_info; + struct { + uint64_t addr; + uint64_t mask; + uint32_t ctrl; + uint32_t pad; + } dbg_regs[8]; +}; + +#define PTRACE_SYSEMU 0x1f +#define PTRACE_SYSEMU_SINGLESTEP 0x20 + +#endif /* _ASM_PTRACE_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/reg.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/reg.h new file mode 100644 index 0000000000000000000000000000000000000000..90ad910c60eb3179eb44b388193665f8f1df35dd --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/reg.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Various register offset definitions for debuggers, core file + * examiners and whatnot. + * + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ + +#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 + +/* + * 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-6.6/prebuilts/usr/include/asm-loongarch/asm/resource.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/resource.h new file mode 100644 index 0000000000000000000000000000000000000000..49a81fbab43d9436df3876feb60cb87d86cbed4c --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/resource.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sembuf.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sembuf.h new file mode 100644 index 0000000000000000000000000000000000000000..d95eae8b3782c0c4543e868362f10ff2ac73287c --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sembuf.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/setup.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/setup.h new file mode 100644 index 0000000000000000000000000000000000000000..4bd19f80f9b0b3134fa2dafb9c7d311515b76423 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/setup.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/shmbuf.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/shmbuf.h new file mode 100644 index 0000000000000000000000000000000000000000..617f564fdd2421b6cfdbd7c5fb8341fb11448f79 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/shmbuf.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h new file mode 100644 index 0000000000000000000000000000000000000000..ea318eccd5eb705772e7df8a5eccadc5174249c5 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sigcontext.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Author: Hanlu Li + * Huacai Chen + * + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#ifndef _ASM_SIGCONTEXT_H +#define _ASM_SIGCONTEXT_H + +#include +#include + +/* 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))); +}; + +#define CONTEXT_INFO_ALIGN 16 +struct sctx_info { + __u32 magic; + __u32 size; + __u64 padding; /* padding to 16 bytes */ +}; + +/* FPU context */ +#define FPU_CTX_MAGIC 0x46505501 +#define FPU_CTX_ALIGN 8 +struct fpu_context { + __u64 regs[32]; + __u64 fcc; + __u32 fcsr; +}; + +/* LSX context */ +#define LSX_CTX_MAGIC 0x53580001 +#define LSX_CTX_ALIGN 16 +struct lsx_context { + __u64 regs[2*32]; + __u64 fcc; + __u32 fcsr; +}; + +/* LASX context */ +#define LASX_CTX_MAGIC 0x41535801 +#define LASX_CTX_ALIGN 32 +struct lasx_context { + __u64 regs[4*32]; + __u64 fcc; + __u32 fcsr; +}; + +/* LBT context */ +#define LBT_CTX_MAGIC 0x42540001 +#define LBT_CTX_ALIGN 8 +struct lbt_context { + __u64 regs[4]; + __u32 eflags; + __u32 ftop; +}; + + +#endif /* _ASM_SIGCONTEXT_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/siginfo.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/siginfo.h new file mode 100644 index 0000000000000000000000000000000000000000..668e5e013171cefa0ab6f0bbcf20c782981a83d1 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/siginfo.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/signal.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/signal.h new file mode 100644 index 0000000000000000000000000000000000000000..2fe75e7b782e74d6ef39b22bf01cfe814753d918 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/signal.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#ifndef _ASM_SIGNAL_H +#define _ASM_SIGNAL_H + +#define MINSIGSTKSZ 4096 +#define SIGSTKSZ 16384 + +#include + +#endif diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/socket.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/socket.h new file mode 100644 index 0000000000000000000000000000000000000000..770aaa96f7c64d54072cfae3b4b1a23154068c0b --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/socket.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sockios.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sockios.h new file mode 100644 index 0000000000000000000000000000000000000000..5c89ac629afecc2de254d33c0b669dacb8359938 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/sockios.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/stat.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/stat.h new file mode 100644 index 0000000000000000000000000000000000000000..edbb13d7b93b6e3034b11ab8fb1e70d6588d8e0a --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/stat.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/statfs.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/statfs.h new file mode 100644 index 0000000000000000000000000000000000000000..608243f59f9e24fb4952fa3edf1381264cab34bd --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/statfs.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/swab.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/swab.h new file mode 100644 index 0000000000000000000000000000000000000000..316e556fc1b90010ea116ccba54fc078fc24d594 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/swab.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termbits.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termbits.h new file mode 100644 index 0000000000000000000000000000000000000000..e8a957095804e82fea1c5dfa46a80339ed715d33 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termbits.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termios.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termios.h new file mode 100644 index 0000000000000000000000000000000000000000..ec082a97874fdabdf3bee4c43c5b3b3b76f3ccb8 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/termios.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/types.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/types.h new file mode 100644 index 0000000000000000000000000000000000000000..68100e108ea6090d34ca6e6ad5ec3559e0727048 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/types.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ucontext.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ucontext.h new file mode 100644 index 0000000000000000000000000000000000000000..12577e22b1c710e43d9d6d25e29eef55792f2b99 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/ucontext.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#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; + /* 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 /* __LOONGARCH_UAPI_ASM_UCONTEXT_H */ diff --git a/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/unistd.h b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/unistd.h new file mode 100644 index 0000000000000000000000000000000000000000..c0b9c5eda7c252c2e7831fcc27ca269efc540b14 --- /dev/null +++ b/linux-6.6/prebuilts/usr/include/asm-loongarch/asm/unistd.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#define __ARCH_WANT_SYS_CLONE +#define __ARCH_WANT_SYS_CLONE3 +#define __ARCH_WANT_NEW_STAT + +#include diff --git a/linux-6.6/prebuilts/usr/include/linux/audit.h b/linux-6.6/prebuilts/usr/include/linux/audit.h index 2c18e0795b1276f071f5c72e7af83b6b40cc8709..78059e2cf9bfa4c76a0fc453b6ea0f099c3a7d5f 100644 --- a/linux-6.6/prebuilts/usr/include/linux/audit.h +++ b/linux-6.6/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-6.6/prebuilts/usr/include/linux/elf-em.h b/linux-6.6/prebuilts/usr/include/linux/elf-em.h index d1ed1f6ce063eb0e2872436d932361afac6f222d..18ea87150fa77c9ad22216e7743896c625b6b779 100644 --- a/linux-6.6/prebuilts/usr/include/linux/elf-em.h +++ b/linux-6.6/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 diff --git a/linux-6.6/prebuilts/usr/include/linux/elf.h b/linux-6.6/prebuilts/usr/include/linux/elf.h index f9f122aab9014aee799bc5ea6a834bac3ae7835e..3ecf1f8668c06fd81b03eb7e8f31b9899ee0a608 100644 --- a/linux-6.6/prebuilts/usr/include/linux/elf.h +++ b/linux-6.6/prebuilts/usr/include/linux/elf.h @@ -365,6 +365,13 @@ typedef struct elf64_shdr { #define NT_MIPS_DSP 0x800 #define NT_MIPS_FP_MODE 0x801 #define NT_MIPS_MSA 0x802 +#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ +#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */ +#define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */ +#define NT_LOONGARCH_LASX 0xa03 /* LoongArch Loongson Advanced SIMD Extension registers */ +#define NT_LOONGARCH_LBT 0xa04 /* LoongArch Loongson Binary Translation registers */ +#define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */ +#define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */ #define NT_GNU_PROPERTY_TYPE_0 5 typedef struct elf32_note { Elf32_Word n_namesz; diff --git a/linux-6.6/prebuilts/usr/include/linux/kexec.h b/linux-6.6/prebuilts/usr/include/linux/kexec.h index b2dc88fb4bfd8c300e5a2cb03c17c6f30b244013..91f845abdb898578ec2459a75c6865358d2a9733 100644 --- a/linux-6.6/prebuilts/usr/include/linux/kexec.h +++ b/linux-6.6/prebuilts/usr/include/linux/kexec.h @@ -39,6 +39,7 @@ #define KEXEC_ARCH_MIPS_LE (10 << 16) #define KEXEC_ARCH_MIPS (8 << 16) #define KEXEC_ARCH_AARCH64 (183 << 16) +#define KEXEC_ARCH_LOONGARCH (258 << 16) #define KEXEC_SEGMENT_MAX 16 struct kexec_segment { const void * buf; diff --git a/linux-6.6/prebuilts/usr/include/linux/kvm.h b/linux-6.6/prebuilts/usr/include/linux/kvm.h index a5bc1f2cb53ed9cfd3dd778ee80ca500ae90adbd..8e40db4cda96050cf5d0516164b48bd34ba4005f 100644 --- a/linux-6.6/prebuilts/usr/include/linux/kvm.h +++ b/linux-6.6/prebuilts/usr/include/linux/kvm.h @@ -197,6 +197,7 @@ struct kvm_hyperv_exit { #define KVM_EXIT_ARM_NISV 28 #define KVM_EXIT_X86_RDMSR 29 #define KVM_EXIT_X86_WRMSR 30 +#define KVM_EXIT_LOONGARCH_IOCSR 38 #define KVM_INTERNAL_ERROR_EMULATION 1 #define KVM_INTERNAL_ERROR_SIMUL_EX 2 #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 @@ -245,6 +246,13 @@ struct kvm_run { __u32 len; __u8 is_write; } mmio; + /* KVM_EXIT_LOONGARCH_IOCSR */ + struct { + __u64 phys_addr; + __u8 data[8]; + __u32 len; + __u8 is_write; + } iocsr_io; struct { __u64 nr; __u64 args[6]; @@ -938,6 +946,7 @@ struct kvm_dirty_tlb { #define KVM_REG_ARM64 0x6000000000000000ULL #define KVM_REG_MIPS 0x7000000000000000ULL #define KVM_REG_RISCV 0x8000000000000000ULL +#define KVM_REG_LOONGARCH 0x9000000000000000ULL #define KVM_REG_SIZE_SHIFT 52 #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL #define KVM_REG_SIZE_U8 0x0000000000000000ULL