11bd4fe43Sopenharmony_ci/* 21bd4fe43Sopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 61bd4fe43Sopenharmony_ci * 71bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 131bd4fe43Sopenharmony_ci * limitations under the License. 141bd4fe43Sopenharmony_ci */ 151bd4fe43Sopenharmony_ci 161bd4fe43Sopenharmony_ci#ifndef __HI_OSAL__ 171bd4fe43Sopenharmony_ci#define __HI_OSAL__ 181bd4fe43Sopenharmony_ci 191bd4fe43Sopenharmony_ci#define HI_OSAL_VERSION "1.0" 201bd4fe43Sopenharmony_ci 211bd4fe43Sopenharmony_ci#include "osal_list.h" 221bd4fe43Sopenharmony_ci#include "autoconf.h" 231bd4fe43Sopenharmony_ci 241bd4fe43Sopenharmony_ci#define osal_gfp_kernel 0 251bd4fe43Sopenharmony_ci#define osal_gfp_atomic 1 261bd4fe43Sopenharmony_ciextern void *osal_vmalloc(unsigned long size); 271bd4fe43Sopenharmony_ciextern void osal_vfree(const void *addr); 281bd4fe43Sopenharmony_ciextern void *osal_kmalloc(unsigned long size, unsigned int osal_gfp_flag); 291bd4fe43Sopenharmony_ciextern void osal_kfree(const void *addr); 301bd4fe43Sopenharmony_ci 311bd4fe43Sopenharmony_ci/* atomic api */ 321bd4fe43Sopenharmony_citypedef struct { 331bd4fe43Sopenharmony_ci void *atomic; 341bd4fe43Sopenharmony_ci} osal_atomic_t; 351bd4fe43Sopenharmony_ci 361bd4fe43Sopenharmony_ci#define OSAL_ATOMIC_INIT(i) { (i) } 371bd4fe43Sopenharmony_ci 381bd4fe43Sopenharmony_ciextern int osal_atomic_init(osal_atomic_t *atomic); 391bd4fe43Sopenharmony_ciextern void osal_atomic_destroy(osal_atomic_t *atomic); 401bd4fe43Sopenharmony_ciextern int osal_atomic_read(osal_atomic_t *v); 411bd4fe43Sopenharmony_ciextern void osal_atomic_set(osal_atomic_t *v, int i); 421bd4fe43Sopenharmony_ciextern int osal_atomic_inc_return(osal_atomic_t *v); 431bd4fe43Sopenharmony_ciextern int osal_atomic_dec_return(osal_atomic_t *v); 441bd4fe43Sopenharmony_ci 451bd4fe43Sopenharmony_ci/* semaphore api */ 461bd4fe43Sopenharmony_ci#define EINTR 4 471bd4fe43Sopenharmony_citypedef struct osal_semaphore { 481bd4fe43Sopenharmony_ci void *sem; 491bd4fe43Sopenharmony_ci} osal_semaphore_t; 501bd4fe43Sopenharmony_ciextern int osal_sema_init(osal_semaphore_t *sem, int val); 511bd4fe43Sopenharmony_ciextern int osal_down(osal_semaphore_t *sem); 521bd4fe43Sopenharmony_ciextern int osal_down_interruptible(osal_semaphore_t *sem); 531bd4fe43Sopenharmony_ciextern int osal_down_trylock(osal_semaphore_t *sem); 541bd4fe43Sopenharmony_ciextern void osal_up(osal_semaphore_t *sem); 551bd4fe43Sopenharmony_ci/* notice:must be called when kmod exit, other wise will lead to memory leak; */ 561bd4fe43Sopenharmony_ciextern void osal_sema_destroy(osal_semaphore_t *sem); 571bd4fe43Sopenharmony_ci 581bd4fe43Sopenharmony_ci/* mutex api */ 591bd4fe43Sopenharmony_citypedef struct osal_mutex { 601bd4fe43Sopenharmony_ci void *mutex; 611bd4fe43Sopenharmony_ci} osal_mutex_t; 621bd4fe43Sopenharmony_ciextern int osal_mutex_init(osal_mutex_t *mutex); 631bd4fe43Sopenharmony_ciextern int osal_mutex_lock(osal_mutex_t *mutex); 641bd4fe43Sopenharmony_ciextern int osal_mutex_lock_interruptible(osal_mutex_t *mutex); 651bd4fe43Sopenharmony_ciextern int osal_mutex_trylock(osal_mutex_t *mutex); 661bd4fe43Sopenharmony_ciextern void osal_mutex_unlock(osal_mutex_t *mutex); 671bd4fe43Sopenharmony_ci/* notice:must be called when kmod exit, other wise will lead to memory leak; */ 681bd4fe43Sopenharmony_ciextern void osal_mutex_destroy(osal_mutex_t *mutex); 691bd4fe43Sopenharmony_ci 701bd4fe43Sopenharmony_ci/* spin lock api */ 711bd4fe43Sopenharmony_citypedef struct osal_spinlock { 721bd4fe43Sopenharmony_ci void *lock; 731bd4fe43Sopenharmony_ci} osal_spinlock_t; 741bd4fe43Sopenharmony_ciextern int osal_spin_lock_init(osal_spinlock_t *lock); 751bd4fe43Sopenharmony_ciextern void osal_spin_lock(osal_spinlock_t *lock); 761bd4fe43Sopenharmony_ciextern int osal_spin_trylock(osal_spinlock_t *lock); 771bd4fe43Sopenharmony_ciextern void osal_spin_unlock(osal_spinlock_t *lock); 781bd4fe43Sopenharmony_ciextern void osal_spin_lock_irqsave(osal_spinlock_t *lock, unsigned long *flags); 791bd4fe43Sopenharmony_ciextern void osal_spin_unlock_irqrestore(osal_spinlock_t *lock, const unsigned long *flags); 801bd4fe43Sopenharmony_ci/* notice:must be called when kmod exit, other wise will lead to memory leak; */ 811bd4fe43Sopenharmony_ciextern void osal_spin_lock_destroy(osal_spinlock_t *lock); 821bd4fe43Sopenharmony_ci 831bd4fe43Sopenharmony_ci/* wait api */ 841bd4fe43Sopenharmony_citypedef int (*osal_wait_cond_func_t)(const void *param); 851bd4fe43Sopenharmony_ci 861bd4fe43Sopenharmony_citypedef struct osal_wait { 871bd4fe43Sopenharmony_ci void *wait; 881bd4fe43Sopenharmony_ci} osal_wait_t; 891bd4fe43Sopenharmony_ci#define ERESTARTSYS 512 901bd4fe43Sopenharmony_ci 911bd4fe43Sopenharmony_ci 921bd4fe43Sopenharmony_ciextern unsigned long osal_msecs_to_jiffies(const unsigned int m); 931bd4fe43Sopenharmony_ciextern int osal_wait_init(osal_wait_t *wait); 941bd4fe43Sopenharmony_ciextern int osal_wait_interruptible(osal_wait_t *wait, osal_wait_cond_func_t func, const void *param); 951bd4fe43Sopenharmony_ciextern int osal_wait_uninterruptible(osal_wait_t *wait, osal_wait_cond_func_t func, const void *param); 961bd4fe43Sopenharmony_ciextern int osal_wait_timeout_interruptible(osal_wait_t *wait, osal_wait_cond_func_t func, const void *param, 971bd4fe43Sopenharmony_ci unsigned long ms); 981bd4fe43Sopenharmony_ciextern int osal_wait_timeout_uninterruptible(osal_wait_t *wait, osal_wait_cond_func_t func, const void *param, 991bd4fe43Sopenharmony_ci unsigned long ms); 1001bd4fe43Sopenharmony_ci 1011bd4fe43Sopenharmony_ci#define osal_wait_event_interruptible(wait, func, param) \ 1021bd4fe43Sopenharmony_ci ({ \ 1031bd4fe43Sopenharmony_ci int __ret = 0; \ 1041bd4fe43Sopenharmony_ci \ 1051bd4fe43Sopenharmony_ci for (;;) { \ 1061bd4fe43Sopenharmony_ci if (func(param) != 0) { \ 1071bd4fe43Sopenharmony_ci __ret = 0; \ 1081bd4fe43Sopenharmony_ci break; \ 1091bd4fe43Sopenharmony_ci } \ 1101bd4fe43Sopenharmony_ci __ret = osal_wait_timeout_interruptible(wait, (func), param, 100); \ 1111bd4fe43Sopenharmony_ci if (__ret < 0) { \ 1121bd4fe43Sopenharmony_ci break; \ 1131bd4fe43Sopenharmony_ci } \ 1141bd4fe43Sopenharmony_ci } \ 1151bd4fe43Sopenharmony_ci __ret; \ 1161bd4fe43Sopenharmony_ci }) 1171bd4fe43Sopenharmony_ci 1181bd4fe43Sopenharmony_ci#define osal_wait_event_uninterruptible(wait, func, param) \ 1191bd4fe43Sopenharmony_ci ({ \ 1201bd4fe43Sopenharmony_ci int __ret = 0; \ 1211bd4fe43Sopenharmony_ci \ 1221bd4fe43Sopenharmony_ci for (;;) { \ 1231bd4fe43Sopenharmony_ci if (func(param) != 0) { \ 1241bd4fe43Sopenharmony_ci __ret = 0; \ 1251bd4fe43Sopenharmony_ci break; \ 1261bd4fe43Sopenharmony_ci } \ 1271bd4fe43Sopenharmony_ci __ret = osal_wait_uninterruptible(wait, (func), param); \ 1281bd4fe43Sopenharmony_ci if (__ret < 0) { \ 1291bd4fe43Sopenharmony_ci break; \ 1301bd4fe43Sopenharmony_ci } \ 1311bd4fe43Sopenharmony_ci } \ 1321bd4fe43Sopenharmony_ci __ret; \ 1331bd4fe43Sopenharmony_ci }) 1341bd4fe43Sopenharmony_ci 1351bd4fe43Sopenharmony_ci#define osal_wait_event_timeout_interruptible(wait, func, param, timeout) \ 1361bd4fe43Sopenharmony_ci ({ \ 1371bd4fe43Sopenharmony_ci int __ret = timeout; \ 1381bd4fe43Sopenharmony_ci \ 1391bd4fe43Sopenharmony_ci if ((func(param) != 0) && ((timeout) == 0)) { \ 1401bd4fe43Sopenharmony_ci __ret = 1; \ 1411bd4fe43Sopenharmony_ci } \ 1421bd4fe43Sopenharmony_ci \ 1431bd4fe43Sopenharmony_ci for (;;) { \ 1441bd4fe43Sopenharmony_ci if (func(param) != 0) { \ 1451bd4fe43Sopenharmony_ci __ret = osal_msecs_to_jiffies(__ret); \ 1461bd4fe43Sopenharmony_ci break; \ 1471bd4fe43Sopenharmony_ci } \ 1481bd4fe43Sopenharmony_ci __ret = osal_wait_timeout_interruptible(wait, (func), param, __ret); \ 1491bd4fe43Sopenharmony_ci if ((__ret == 0) || (__ret == -ERESTARTSYS)) { \ 1501bd4fe43Sopenharmony_ci break; \ 1511bd4fe43Sopenharmony_ci } \ 1521bd4fe43Sopenharmony_ci } \ 1531bd4fe43Sopenharmony_ci __ret; \ 1541bd4fe43Sopenharmony_ci }) 1551bd4fe43Sopenharmony_ci 1561bd4fe43Sopenharmony_ci#define osal_wait_event_timeout_uninterruptible(wait, func, param, timeout) \ 1571bd4fe43Sopenharmony_ci ({ \ 1581bd4fe43Sopenharmony_ci int __ret = timeout; \ 1591bd4fe43Sopenharmony_ci \ 1601bd4fe43Sopenharmony_ci if ((func(param) != 0) && ((timeout) == 0)) { \ 1611bd4fe43Sopenharmony_ci __ret = 1; \ 1621bd4fe43Sopenharmony_ci } \ 1631bd4fe43Sopenharmony_ci \ 1641bd4fe43Sopenharmony_ci for (;;) { \ 1651bd4fe43Sopenharmony_ci if (func(param) != 0) { \ 1661bd4fe43Sopenharmony_ci __ret = osal_msecs_to_jiffies(__ret); \ 1671bd4fe43Sopenharmony_ci break; \ 1681bd4fe43Sopenharmony_ci } \ 1691bd4fe43Sopenharmony_ci __ret = osal_wait_timeout_uninterruptible(wait, (func), param, __ret); \ 1701bd4fe43Sopenharmony_ci if ((__ret == 0) || (__ret == -ERESTARTSYS)) { \ 1711bd4fe43Sopenharmony_ci break; \ 1721bd4fe43Sopenharmony_ci } \ 1731bd4fe43Sopenharmony_ci } \ 1741bd4fe43Sopenharmony_ci __ret; \ 1751bd4fe43Sopenharmony_ci }) 1761bd4fe43Sopenharmony_ci 1771bd4fe43Sopenharmony_ciextern void osal_wakeup(osal_wait_t *wait); /* same as wake_up_all */ 1781bd4fe43Sopenharmony_ciextern void osal_wait_destroy(osal_wait_t *wait); 1791bd4fe43Sopenharmony_ci 1801bd4fe43Sopenharmony_ci/* workqueue api */ 1811bd4fe43Sopenharmony_citypedef struct osal_work_struct { 1821bd4fe43Sopenharmony_ci int queue_flag; 1831bd4fe43Sopenharmony_ci void *work; 1841bd4fe43Sopenharmony_ci void (*func)(struct osal_work_struct *work); 1851bd4fe43Sopenharmony_ci} osal_work_struct_t; 1861bd4fe43Sopenharmony_citypedef void (*osal_work_func_t)(struct osal_work_struct *work); 1871bd4fe43Sopenharmony_ci 1881bd4fe43Sopenharmony_ciextern int osal_init_work(struct osal_work_struct *work, osal_work_func_t func); 1891bd4fe43Sopenharmony_ci 1901bd4fe43Sopenharmony_ci#define OSAL_INIT_WORK(_work, _func) \ 1911bd4fe43Sopenharmony_ci do { \ 1921bd4fe43Sopenharmony_ci osal_init_work((_work), (_func)); \ 1931bd4fe43Sopenharmony_ci } while (0) 1941bd4fe43Sopenharmony_ci 1951bd4fe43Sopenharmony_ciextern int osal_schedule_work(struct osal_work_struct *work); 1961bd4fe43Sopenharmony_ciextern void osal_destroy_work(struct osal_work_struct *work); 1971bd4fe43Sopenharmony_ci 1981bd4fe43Sopenharmony_ci/* schedule */ 1991bd4fe43Sopenharmony_ciextern void osal_yield(void); 2001bd4fe43Sopenharmony_ci 2011bd4fe43Sopenharmony_ci/* interrupt api */ 2021bd4fe43Sopenharmony_cienum osal_irqreturn { 2031bd4fe43Sopenharmony_ci OSAL_IRQ_NONE = (0 << 0), 2041bd4fe43Sopenharmony_ci OSAL_IRQ_HANDLED = (1 << 0), 2051bd4fe43Sopenharmony_ci OSAL_IRQ_WAKE_THREAD = (1 << 1), 2061bd4fe43Sopenharmony_ci}; 2071bd4fe43Sopenharmony_ci 2081bd4fe43Sopenharmony_citypedef int (*osal_irq_handler_t)(int, void *); 2091bd4fe43Sopenharmony_ciextern int osal_request_irq(unsigned int irq, osal_irq_handler_t handler, osal_irq_handler_t thread_fn, 2101bd4fe43Sopenharmony_ci const char *name, void *dev); 2111bd4fe43Sopenharmony_ciextern void osal_free_irq(unsigned int irq, void *dev); 2121bd4fe43Sopenharmony_ciextern int osal_in_interrupt(void); 2131bd4fe43Sopenharmony_ci 2141bd4fe43Sopenharmony_ci#define OSAL_DIS_IRQ_CNT 2 2151bd4fe43Sopenharmony_citypedef void (*osal_gic_handle_t)(unsigned int, unsigned int, void *); 2161bd4fe43Sopenharmony_ciextern int osal_register_gic_handle(unsigned int index, unsigned int irq, osal_gic_handle_t handle, const char *name, 2171bd4fe43Sopenharmony_ci void *dev); 2181bd4fe43Sopenharmony_ciextern int osal_unregister_gic_handle(unsigned int index, unsigned int irq, void *dev); 2191bd4fe43Sopenharmony_ci 2201bd4fe43Sopenharmony_ci/* task api */ 2211bd4fe43Sopenharmony_citypedef struct osal_task { 2221bd4fe43Sopenharmony_ci void *task_struct; 2231bd4fe43Sopenharmony_ci} osal_task_t; 2241bd4fe43Sopenharmony_citypedef int (*threadfn_t)(void *data); 2251bd4fe43Sopenharmony_ciextern osal_task_t *osal_kthread_create(threadfn_t thread, void *data, const char *name); 2261bd4fe43Sopenharmony_ciextern void osal_kthread_destroy(osal_task_t *task, unsigned int stop_flag); 2271bd4fe43Sopenharmony_ci 2281bd4fe43Sopenharmony_ci/* string api */ 2291bd4fe43Sopenharmony_ciextern int osal_strcmp(const char *s1, const char *s2); 2301bd4fe43Sopenharmony_ciextern int osal_strncmp(const char *s1, const char *s2, int size); 2311bd4fe43Sopenharmony_ciextern int osal_strnicmp(const char *s1, const char *s2, int size); 2321bd4fe43Sopenharmony_ciextern int osal_strcasecmp(const char *s1, const char *s2); 2331bd4fe43Sopenharmony_ciextern int osal_strncasecmp(const char *s1, const char *s2, int n); 2341bd4fe43Sopenharmony_ciextern char *osal_strchr(const char *s, int n); 2351bd4fe43Sopenharmony_ciextern char *osal_strnchr(const char *s, int count, int c); 2361bd4fe43Sopenharmony_ciextern char *osal_strrchr(const char *s, int c); 2371bd4fe43Sopenharmony_ciextern char *osal_strstr(const char *s1, const char *s2); 2381bd4fe43Sopenharmony_ciextern char *osal_strnstr(const char *s1, const char *s2, int n); 2391bd4fe43Sopenharmony_ciextern int osal_strlen(const char *s); 2401bd4fe43Sopenharmony_ciextern int osal_strnlen(const char *s, int size); 2411bd4fe43Sopenharmony_ciextern char *osal_strpbrk(const char *s1, const char *s2); 2421bd4fe43Sopenharmony_ciextern char *osal_strsep(char **s, const char *ct); 2431bd4fe43Sopenharmony_ciextern int osal_strspn(const char *s, const char *accept); 2441bd4fe43Sopenharmony_ciextern int osal_strcspn(const char *s, const char *reject); 2451bd4fe43Sopenharmony_ciextern void *osal_memscan(void *addr, int c, int size); 2461bd4fe43Sopenharmony_ciextern int osal_memcmp(const void *cs, const void *ct, int count); 2471bd4fe43Sopenharmony_ciextern void *osal_memchr(const void *s, int c, int n); 2481bd4fe43Sopenharmony_ciextern void *osal_memchr_inv(const void *s, int c, int n); 2491bd4fe43Sopenharmony_ci 2501bd4fe43Sopenharmony_ciextern unsigned long long osal_strtoull(const char *cp, char **endp, unsigned int base); 2511bd4fe43Sopenharmony_ciextern unsigned long osal_strtoul(const char *cp, char **endp, unsigned int base); 2521bd4fe43Sopenharmony_ciextern long osal_strtol(const char *cp, char **endp, unsigned int base); 2531bd4fe43Sopenharmony_ciextern long long osal_strtoll(const char *cp, char **endp, unsigned int base); 2541bd4fe43Sopenharmony_ci 2551bd4fe43Sopenharmony_ci/* addr translate */ 2561bd4fe43Sopenharmony_ciextern void *osal_ioremap(unsigned long phys_addr, unsigned long size); 2571bd4fe43Sopenharmony_ciextern void *osal_ioremap_nocache(unsigned long phys_addr, unsigned long size); 2581bd4fe43Sopenharmony_ciextern void *osal_ioremap_cached(unsigned long phys_addr, unsigned long size); 2591bd4fe43Sopenharmony_ciextern void *osal_ioremap_wc(unsigned long phys_addr, unsigned long size); 2601bd4fe43Sopenharmony_ciextern void osal_iounmap(void *addr, unsigned long size); 2611bd4fe43Sopenharmony_ci 2621bd4fe43Sopenharmony_ci#define osal_readl(x) (*((volatile int *)(x))) 2631bd4fe43Sopenharmony_ci#define osal_writel(v, x) (*((volatile int *)(x)) = (v)) 2641bd4fe43Sopenharmony_ci 2651bd4fe43Sopenharmony_ciextern unsigned long osal_copy_from_user(void *to, const void *from, unsigned long n); 2661bd4fe43Sopenharmony_ciextern unsigned long osal_copy_to_user(void *to, const void *from, unsigned long n); 2671bd4fe43Sopenharmony_ci 2681bd4fe43Sopenharmony_ci#define OSAL_VERIFY_READ 0 2691bd4fe43Sopenharmony_ci#define OSAL_VERIFY_WRITE 1 2701bd4fe43Sopenharmony_ciextern int osal_access_ok(int type, const void *addr, unsigned long size); 2711bd4fe43Sopenharmony_ci 2721bd4fe43Sopenharmony_ci/* cache api */ 2731bd4fe43Sopenharmony_ciextern void osal_flush_dcache_area(void *kvirt, unsigned long phys_addr, unsigned long length); 2741bd4fe43Sopenharmony_ci 2751bd4fe43Sopenharmony_ci/* math */ 2761bd4fe43Sopenharmony_ciextern unsigned long long osal_div_u64(unsigned long long dividend, unsigned int divisor); 2771bd4fe43Sopenharmony_ciextern long long osal_div_s64(long long dividend, int divisor); 2781bd4fe43Sopenharmony_ciextern unsigned long long osal_div64_u64(unsigned long long dividend, unsigned long long divisor); 2791bd4fe43Sopenharmony_ciextern long long osal_div64_s64(long long dividend, long long divisor); 2801bd4fe43Sopenharmony_ciextern unsigned long long osal_div_u64_rem(unsigned long long dividend, unsigned int divisor); 2811bd4fe43Sopenharmony_ciextern long long osal_div_s64_rem(long long dividend, int divisor); 2821bd4fe43Sopenharmony_ciextern unsigned long long osal_div64_u64_rem(unsigned long long dividend, unsigned long long divisor); 2831bd4fe43Sopenharmony_ciextern unsigned int osal_random(void); 2841bd4fe43Sopenharmony_ci 2851bd4fe43Sopenharmony_ci#define osal_max(x, y) ({ \ 2861bd4fe43Sopenharmony_ci __typeof__(x) _max1 = (x); \ 2871bd4fe43Sopenharmony_ci __typeof__(y) _max2 = (y); \ 2881bd4fe43Sopenharmony_ci (void) (&_max1 == &_max2); \ 2891bd4fe43Sopenharmony_ci _max1 > _max2 ? _max1 : _max2; }) 2901bd4fe43Sopenharmony_ci 2911bd4fe43Sopenharmony_ci#define osal_min(x, y) ({ \ 2921bd4fe43Sopenharmony_ci __typeof__(x) _min1 = (x); \ 2931bd4fe43Sopenharmony_ci __typeof__(y) _min2 = (y); \ 2941bd4fe43Sopenharmony_ci (void) (&_min1 == &_min2); \ 2951bd4fe43Sopenharmony_ci _min1 < _min2 ? _min1 : _min2; }) 2961bd4fe43Sopenharmony_ci 2971bd4fe43Sopenharmony_ci#define osal_abs(x) ({ \ 2981bd4fe43Sopenharmony_ci long ret; \ 2991bd4fe43Sopenharmony_ci if (sizeof(x) == sizeof(long)) { \ 3001bd4fe43Sopenharmony_ci long __x = (x); \ 3011bd4fe43Sopenharmony_ci ret = (__x < 0) ? -__x : __x; \ 3021bd4fe43Sopenharmony_ci } else { \ 3031bd4fe43Sopenharmony_ci int __x = (x); \ 3041bd4fe43Sopenharmony_ci ret = (__x < 0) ? -__x : __x; \ 3051bd4fe43Sopenharmony_ci } \ 3061bd4fe43Sopenharmony_ci ret; \ 3071bd4fe43Sopenharmony_ci}) 3081bd4fe43Sopenharmony_ci 3091bd4fe43Sopenharmony_ci/* barrier */ 3101bd4fe43Sopenharmony_ciextern void osal_mb(void); 3111bd4fe43Sopenharmony_ciextern void osal_rmb(void); 3121bd4fe43Sopenharmony_ciextern void osal_wmb(void); 3131bd4fe43Sopenharmony_ciextern void osal_smp_mb(void); 3141bd4fe43Sopenharmony_ciextern void osal_smp_rmb(void); 3151bd4fe43Sopenharmony_ciextern void osal_smp_wmb(void); 3161bd4fe43Sopenharmony_ciextern void osal_isb(void); 3171bd4fe43Sopenharmony_ciextern void osal_dsb(void); 3181bd4fe43Sopenharmony_ciextern void osal_dmb(void); 3191bd4fe43Sopenharmony_ci 3201bd4fe43Sopenharmony_ci/* debug */ 3211bd4fe43Sopenharmony_ciextern int osal_printk(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 3221bd4fe43Sopenharmony_ciextern void osal_panic(const char *fmt, const char *fun, int line, const char *); 3231bd4fe43Sopenharmony_ci#define OSAL_BUG() \ 3241bd4fe43Sopenharmony_ci do { \ 3251bd4fe43Sopenharmony_ci } while (1) 3261bd4fe43Sopenharmony_ci 3271bd4fe43Sopenharmony_ci#define OSAL_ASSERT(expr) \ 3281bd4fe43Sopenharmony_ci do { \ 3291bd4fe43Sopenharmony_ci if (!(expr)) { \ 3301bd4fe43Sopenharmony_ci osal_printk("\nASSERT failed at:\n" \ 3311bd4fe43Sopenharmony_ci " >Condition: %s\n", \ 3321bd4fe43Sopenharmony_ci #expr); \ 3331bd4fe43Sopenharmony_ci OSAL_BUG(); \ 3341bd4fe43Sopenharmony_ci } \ 3351bd4fe43Sopenharmony_ci } while (0) 3361bd4fe43Sopenharmony_ci 3371bd4fe43Sopenharmony_ci#define OSAL_BUG_ON(expr) \ 3381bd4fe43Sopenharmony_ci do { \ 3391bd4fe43Sopenharmony_ci if (expr) { \ 3401bd4fe43Sopenharmony_ci osal_printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ 3411bd4fe43Sopenharmony_ci OSAL_BUG(); \ 3421bd4fe43Sopenharmony_ci } \ 3431bd4fe43Sopenharmony_ci } while (0) 3441bd4fe43Sopenharmony_ci 3451bd4fe43Sopenharmony_ci#ifdef CONFIG_HI_LOG_TRACE_SUPPORT 3461bd4fe43Sopenharmony_ci#define osal_trace osal_printk 3471bd4fe43Sopenharmony_ci#else 3481bd4fe43Sopenharmony_ci#define osal_trace(str, fmt...) 3491bd4fe43Sopenharmony_ci#endif 3501bd4fe43Sopenharmony_ci 3511bd4fe43Sopenharmony_ci/* proc */ 3521bd4fe43Sopenharmony_ci#define OSAL_MAX_PROC_NAME_LEN 50 3531bd4fe43Sopenharmony_citypedef struct osal_proc_dir_entry { 3541bd4fe43Sopenharmony_ci char name[OSAL_MAX_PROC_NAME_LEN]; 3551bd4fe43Sopenharmony_ci void *proc_dir_entry; 3561bd4fe43Sopenharmony_ci int (*open)(struct osal_proc_dir_entry *entry); 3571bd4fe43Sopenharmony_ci int (*read)(struct osal_proc_dir_entry *entry); 3581bd4fe43Sopenharmony_ci int (*write)(struct osal_proc_dir_entry *entry, const char *buf, int count, long long *); 3591bd4fe43Sopenharmony_ci void *private; 3601bd4fe43Sopenharmony_ci void *seqfile; 3611bd4fe43Sopenharmony_ci struct osal_list_head node; 3621bd4fe43Sopenharmony_ci} osal_proc_entry_t; 3631bd4fe43Sopenharmony_ciextern osal_proc_entry_t *osal_create_proc_entry(const char *name, osal_proc_entry_t *parent); 3641bd4fe43Sopenharmony_ciextern osal_proc_entry_t *osal_proc_mkdir(const char *name, osal_proc_entry_t *parent); 3651bd4fe43Sopenharmony_ciextern void osal_remove_proc_entry(const char *name, osal_proc_entry_t *parent); 3661bd4fe43Sopenharmony_ciextern void osal_seq_printf(osal_proc_entry_t *entry, const char *fmt, ...) __attribute__((format(printf, 2, 3))); 3671bd4fe43Sopenharmony_ci 3681bd4fe43Sopenharmony_ci/* device api */ 3691bd4fe43Sopenharmony_ci#ifndef _IOC_TYPECHECK 3701bd4fe43Sopenharmony_ci#include "osal_ioctl.h" 3711bd4fe43Sopenharmony_ci#endif 3721bd4fe43Sopenharmony_ci#define OSAL_MAX_DEV_NAME_LEN 48 3731bd4fe43Sopenharmony_ci 3741bd4fe43Sopenharmony_citypedef struct osal_dev { 3751bd4fe43Sopenharmony_ci struct osal_list_head list; 3761bd4fe43Sopenharmony_ci char name[OSAL_MAX_DEV_NAME_LEN]; 3771bd4fe43Sopenharmony_ci void *dev; 3781bd4fe43Sopenharmony_ci unsigned int minor; 3791bd4fe43Sopenharmony_ci unsigned int count; 3801bd4fe43Sopenharmony_ci struct osal_fileops *fops; 3811bd4fe43Sopenharmony_ci struct osal_pmops *osal_pmops; 3821bd4fe43Sopenharmony_ci} osal_dev_t; 3831bd4fe43Sopenharmony_ci 3841bd4fe43Sopenharmony_citypedef struct osal_vm { 3851bd4fe43Sopenharmony_ci void *vm; 3861bd4fe43Sopenharmony_ci} osal_vm_t; 3871bd4fe43Sopenharmony_ci 3881bd4fe43Sopenharmony_ci#define OSAL_POLLIN 0x0001U 3891bd4fe43Sopenharmony_ci#define OSAL_POLLPRI 0x0002U 3901bd4fe43Sopenharmony_ci#define OSAL_POLLOUT 0x0004U 3911bd4fe43Sopenharmony_ci#define OSAL_POLLERR 0x0008U 3921bd4fe43Sopenharmony_ci#define OSAL_POLLHUP 0x0010U 3931bd4fe43Sopenharmony_ci#define OSAL_POLLNVAL 0x0020U 3941bd4fe43Sopenharmony_ci#define OSAL_POLLRDNORM 0x0040U 3951bd4fe43Sopenharmony_ci#define OSAL_POLLRDBAND 0x0080U 3961bd4fe43Sopenharmony_ci#define OSAL_POLLWRNORM 0x0100U 3971bd4fe43Sopenharmony_ci 3981bd4fe43Sopenharmony_citypedef struct osal_poll { 3991bd4fe43Sopenharmony_ci void *poll_table; 4001bd4fe43Sopenharmony_ci void *data; 4011bd4fe43Sopenharmony_ci} osal_poll_t; 4021bd4fe43Sopenharmony_ci 4031bd4fe43Sopenharmony_citypedef struct osal_fileops { 4041bd4fe43Sopenharmony_ci int (*open)(void *private_data); 4051bd4fe43Sopenharmony_ci int (*read)(char *buf, int size, long *offset, void *private_data); 4061bd4fe43Sopenharmony_ci int (*write)(const char *buf, int size, long *offset, void *private_data); 4071bd4fe43Sopenharmony_ci long (*llseek)(long offset, int whence, void *private_data); 4081bd4fe43Sopenharmony_ci int (*release)(void *private_data); 4091bd4fe43Sopenharmony_ci long (*unlocked_ioctl)(unsigned int cmd, unsigned long arg, void *private_data); 4101bd4fe43Sopenharmony_ci unsigned int (*poll)(osal_poll_t *osal_poll, void *private_data); 4111bd4fe43Sopenharmony_ci int (*mmap)(osal_vm_t *vm, unsigned long start, unsigned long end, unsigned long vm_pgoff, void *private_data); 4121bd4fe43Sopenharmony_ci#ifdef CONFIG_COMPAT 4131bd4fe43Sopenharmony_ci long (*compat_ioctl)(unsigned int cmd, unsigned long arg, void *private_data); 4141bd4fe43Sopenharmony_ci#endif 4151bd4fe43Sopenharmony_ci} osal_fileops_t; 4161bd4fe43Sopenharmony_ci 4171bd4fe43Sopenharmony_citypedef struct osal_pmops { 4181bd4fe43Sopenharmony_ci int (*pm_prepare)(osal_dev_t *dev); 4191bd4fe43Sopenharmony_ci void (*pm_complete)(osal_dev_t *dev); 4201bd4fe43Sopenharmony_ci int (*pm_suspend)(osal_dev_t *dev); 4211bd4fe43Sopenharmony_ci int (*pm_resume)(osal_dev_t *dev); 4221bd4fe43Sopenharmony_ci int (*pm_freeze)(osal_dev_t *dev); 4231bd4fe43Sopenharmony_ci int (*pm_thaw)(osal_dev_t *dev); 4241bd4fe43Sopenharmony_ci int (*pm_poweroff)(osal_dev_t *dev); 4251bd4fe43Sopenharmony_ci int (*pm_restore)(osal_dev_t *dev); 4261bd4fe43Sopenharmony_ci int (*pm_suspend_late)(osal_dev_t *dev); 4271bd4fe43Sopenharmony_ci int (*pm_resume_early)(osal_dev_t *dev); 4281bd4fe43Sopenharmony_ci int (*pm_freeze_late)(osal_dev_t *dev); 4291bd4fe43Sopenharmony_ci int (*pm_thaw_early)(osal_dev_t *dev); 4301bd4fe43Sopenharmony_ci int (*pm_poweroff_late)(osal_dev_t *dev); 4311bd4fe43Sopenharmony_ci int (*pm_restore_early)(osal_dev_t *dev); 4321bd4fe43Sopenharmony_ci int (*pm_suspend_noirq)(osal_dev_t *dev); 4331bd4fe43Sopenharmony_ci int (*pm_resume_noirq)(osal_dev_t *dev); 4341bd4fe43Sopenharmony_ci int (*pm_freeze_noirq)(osal_dev_t *dev); 4351bd4fe43Sopenharmony_ci int (*pm_thaw_noirq)(osal_dev_t *dev); 4361bd4fe43Sopenharmony_ci int (*pm_poweroff_noirq)(osal_dev_t *dev); 4371bd4fe43Sopenharmony_ci int (*pm_restore_noirq)(osal_dev_t *dev); 4381bd4fe43Sopenharmony_ci} osal_pmops_t; 4391bd4fe43Sopenharmony_ci 4401bd4fe43Sopenharmony_ci#define OSAL_SEEK_SET 0 4411bd4fe43Sopenharmony_ci#define OSAL_SEEK_CUR 1 4421bd4fe43Sopenharmony_ci#define OSAL_SEEK_END 2 4431bd4fe43Sopenharmony_ci 4441bd4fe43Sopenharmony_ciextern osal_dev_t *osal_createdev(const char *name); 4451bd4fe43Sopenharmony_ciextern int osal_destroydev(osal_dev_t *pdev); 4461bd4fe43Sopenharmony_ciextern int osal_registerdevice(osal_dev_t *pdev); 4471bd4fe43Sopenharmony_ciextern void osal_deregisterdevice(osal_dev_t *pdev); 4481bd4fe43Sopenharmony_ciextern void osal_poll_wait(osal_poll_t *table, osal_wait_t *wait); 4491bd4fe43Sopenharmony_ciextern void osal_pgprot_noncached(osal_vm_t *vm); 4501bd4fe43Sopenharmony_ciextern void osal_pgprot_cached(osal_vm_t *vm); 4511bd4fe43Sopenharmony_ciextern void osal_pgprot_writecombine(osal_vm_t *vm); 4521bd4fe43Sopenharmony_ciextern int osal_remap_pfn_range(osal_vm_t *vm, unsigned long addr, unsigned long pfn, unsigned long size); 4531bd4fe43Sopenharmony_ci 4541bd4fe43Sopenharmony_ci/* timer */ 4551bd4fe43Sopenharmony_citypedef struct osal_timer { 4561bd4fe43Sopenharmony_ci void *timer; 4571bd4fe43Sopenharmony_ci void (*function)(unsigned long); 4581bd4fe43Sopenharmony_ci unsigned long data; 4591bd4fe43Sopenharmony_ci} osal_timer_t; 4601bd4fe43Sopenharmony_ci 4611bd4fe43Sopenharmony_citypedef struct osal_timeval { 4621bd4fe43Sopenharmony_ci long tv_sec; 4631bd4fe43Sopenharmony_ci long tv_usec; 4641bd4fe43Sopenharmony_ci} osal_timeval_t; 4651bd4fe43Sopenharmony_ci 4661bd4fe43Sopenharmony_citypedef struct osal_rtc_time { 4671bd4fe43Sopenharmony_ci int tm_sec; 4681bd4fe43Sopenharmony_ci int tm_min; 4691bd4fe43Sopenharmony_ci int tm_hour; 4701bd4fe43Sopenharmony_ci int tm_mday; 4711bd4fe43Sopenharmony_ci int tm_mon; 4721bd4fe43Sopenharmony_ci int tm_year; 4731bd4fe43Sopenharmony_ci int tm_wday; 4741bd4fe43Sopenharmony_ci int tm_yday; 4751bd4fe43Sopenharmony_ci int tm_isdst; 4761bd4fe43Sopenharmony_ci} osal_rtc_time_t; 4771bd4fe43Sopenharmony_ci 4781bd4fe43Sopenharmony_ci/* Return values for the timer callback function */ 4791bd4fe43Sopenharmony_citypedef enum hiOSAL_HRTIMER_RESTART_E { 4801bd4fe43Sopenharmony_ci OSAL_HRTIMER_NORESTART, /* < The timer will not be restarted. */ 4811bd4fe43Sopenharmony_ci OSAL_HRTIMER_RESTART /* < The timer must be restarted. */ 4821bd4fe43Sopenharmony_ci} OSAL_HRTIMER_RESTART_E; 4831bd4fe43Sopenharmony_ci 4841bd4fe43Sopenharmony_ci/* hrtimer struct */ 4851bd4fe43Sopenharmony_citypedef struct osal_hrtimer { 4861bd4fe43Sopenharmony_ci void *timer; 4871bd4fe43Sopenharmony_ci OSAL_HRTIMER_RESTART_E (*function)(void *timer); 4881bd4fe43Sopenharmony_ci unsigned long interval; /* Unit ms */ 4891bd4fe43Sopenharmony_ci} osal_hrtimer_t; 4901bd4fe43Sopenharmony_ci 4911bd4fe43Sopenharmony_ciextern int osal_hrtimer_create(osal_hrtimer_t *phrtimer); 4921bd4fe43Sopenharmony_ciextern int osal_hrtimer_start(osal_hrtimer_t *phrtimer); 4931bd4fe43Sopenharmony_ciextern int osal_hrtimer_destroy(osal_hrtimer_t *phrtimer); 4941bd4fe43Sopenharmony_ci 4951bd4fe43Sopenharmony_ciextern int osal_timer_init(osal_timer_t *timer); 4961bd4fe43Sopenharmony_ciextern int osal_set_timer(osal_timer_t *timer, unsigned long interval); /* ms */ 4971bd4fe43Sopenharmony_ciextern unsigned long osal_timer_get_private_data(void *data); 4981bd4fe43Sopenharmony_ciextern int osal_del_timer(osal_timer_t *timer); 4991bd4fe43Sopenharmony_ciextern int osal_timer_destroy(osal_timer_t *timer); 5001bd4fe43Sopenharmony_ci 5011bd4fe43Sopenharmony_ciextern unsigned long osal_msleep(unsigned int msecs); 5021bd4fe43Sopenharmony_ciextern void osal_udelay(unsigned int usecs); 5031bd4fe43Sopenharmony_ciextern void osal_mdelay(unsigned int msecs); 5041bd4fe43Sopenharmony_ci 5051bd4fe43Sopenharmony_ciextern unsigned int osal_get_tickcount(void); 5061bd4fe43Sopenharmony_ciextern unsigned long long osal_sched_clock(void); 5071bd4fe43Sopenharmony_ciextern void osal_gettimeofday(osal_timeval_t *tv); 5081bd4fe43Sopenharmony_ciextern void osal_rtc_time_to_tm(unsigned long time, osal_rtc_time_t *tm); 5091bd4fe43Sopenharmony_ciextern void osal_rtc_tm_to_time(osal_rtc_time_t *tm, unsigned long *time); 5101bd4fe43Sopenharmony_ciextern int osal_rtc_valid_tm(struct osal_rtc_time *tm); 5111bd4fe43Sopenharmony_ciextern void osal_getjiffies(unsigned long long *pjiffies); 5121bd4fe43Sopenharmony_ci 5131bd4fe43Sopenharmony_ci#define OSAL_O_ACCMODE 00000003 5141bd4fe43Sopenharmony_ci#define OSAL_O_RDONLY 00000000 5151bd4fe43Sopenharmony_ci#define OSAL_O_WRONLY 00000001 5161bd4fe43Sopenharmony_ci#define OSAL_O_RDWR 00000002 5171bd4fe43Sopenharmony_ci#define OSAL_O_CREAT 00000100 5181bd4fe43Sopenharmony_ci 5191bd4fe43Sopenharmony_ciextern void *osal_klib_fopen(const char *filename, int flags, int mode); 5201bd4fe43Sopenharmony_ciextern void osal_klib_fclose(void *filp); 5211bd4fe43Sopenharmony_ciextern int osal_klib_fwrite(const char *buf, int len, void *filp); 5221bd4fe43Sopenharmony_ciextern int osal_klib_fread(char *buf, unsigned int len, void *filp); 5231bd4fe43Sopenharmony_ci 5241bd4fe43Sopenharmony_ci/* reboot */ 5251bd4fe43Sopenharmony_cistruct osal_notifier_block { 5261bd4fe43Sopenharmony_ci int (*notifier_call)(struct osal_notifier_block *nb, unsigned long action, void *data); 5271bd4fe43Sopenharmony_ci void *notifier_block; 5281bd4fe43Sopenharmony_ci}; 5291bd4fe43Sopenharmony_citypedef int (*osal_notifier_fn_t)(struct osal_notifier_block *nb, unsigned long action, void *data); 5301bd4fe43Sopenharmony_ci 5311bd4fe43Sopenharmony_ciextern int osal_register_reboot_notifier(struct osal_notifier_block *nb); 5321bd4fe43Sopenharmony_ciextern int osal_unregister_reboot_notifier(struct osal_notifier_block *nb); 5331bd4fe43Sopenharmony_ci 5341bd4fe43Sopenharmony_ci#include <stdarg.h> 5351bd4fe43Sopenharmony_ci 5361bd4fe43Sopenharmony_ci#ifndef _OSAL_VA_LIST 5371bd4fe43Sopenharmony_ci 5381bd4fe43Sopenharmony_ci#define _OSAL_VA_LIST 5391bd4fe43Sopenharmony_ci#define osal_va_list va_list 5401bd4fe43Sopenharmony_ci#define osal_va_arg(ap, T) va_arg(ap, T) 5411bd4fe43Sopenharmony_ci#define osal_va_end(ap) va_end(ap) 5421bd4fe43Sopenharmony_ci#define osal_va_start(ap, A) va_start(ap, A) 5431bd4fe43Sopenharmony_ci 5441bd4fe43Sopenharmony_ci#endif /* va_arg */ 5451bd4fe43Sopenharmony_ci 5461bd4fe43Sopenharmony_ci#define NULL_STRING "NULL" 5471bd4fe43Sopenharmony_ci 5481bd4fe43Sopenharmony_ciextern void osal_vprintk(const char *fmt, osal_va_list args); 5491bd4fe43Sopenharmony_ci 5501bd4fe43Sopenharmony_ci#define osal_platform_get_module_param(pdev, name, type, value) \ 5511bd4fe43Sopenharmony_ci osal_platform_get_modparam_##type(pdev, name, value) 5521bd4fe43Sopenharmony_ci 5531bd4fe43Sopenharmony_ciint osal_platform_get_modparam_uint(void *pdev, const char *name, unsigned int *value); 5541bd4fe43Sopenharmony_ciint osal_platform_get_modparam_int(void *pdev, const char *name, int *value); 5551bd4fe43Sopenharmony_ciint osal_platform_get_modparam_string(void *pdev, const char *name, unsigned int size, char *value); 5561bd4fe43Sopenharmony_ciint osal_platform_get_modparam_uchar(void *pdev, const char *name, unsigned char *value); 5571bd4fe43Sopenharmony_ciint osal_platform_get_modparam_ushort(void *pdev, const char *name, unsigned short *value); 5581bd4fe43Sopenharmony_ci/* of function */ 5591bd4fe43Sopenharmony_ciint osal_of_property_read_u32(const void *np, const char *propname, unsigned int *value); 5601bd4fe43Sopenharmony_ci 5611bd4fe43Sopenharmony_ciint osal_platform_driver_register(void *drv); 5621bd4fe43Sopenharmony_civoid osal_platform_driver_unregister(void *drv); 5631bd4fe43Sopenharmony_civoid *osal_platform_get_resource_byname(void *dev, unsigned int type, 5641bd4fe43Sopenharmony_ci const char *name); 5651bd4fe43Sopenharmony_civoid *osal_platform_get_resource(void *dev, unsigned int type, 5661bd4fe43Sopenharmony_ci unsigned int num); 5671bd4fe43Sopenharmony_ciint osal_platform_get_irq(void *dev, unsigned int num); 5681bd4fe43Sopenharmony_ciint osal_platform_get_irq_byname(void *dev, const char *name); 5691bd4fe43Sopenharmony_ci 5701bd4fe43Sopenharmony_ci#define osal_module_driver(osal_driver, osal_register, osal_unregister, ...) \ 5711bd4fe43Sopenharmony_ci static int __init osal_driver##_init(void) \ 5721bd4fe43Sopenharmony_ci { \ 5731bd4fe43Sopenharmony_ci return osal_register(&(osal_driver)); \ 5741bd4fe43Sopenharmony_ci } \ 5751bd4fe43Sopenharmony_ci module_init(osal_driver##_init); \ 5761bd4fe43Sopenharmony_ci static void __exit osal_driver##_exit(void) \ 5771bd4fe43Sopenharmony_ci { \ 5781bd4fe43Sopenharmony_ci osal_unregister(&(osal_driver)); \ 5791bd4fe43Sopenharmony_ci } \ 5801bd4fe43Sopenharmony_ci module_exit(osal_driver##_exit); 5811bd4fe43Sopenharmony_ci 5821bd4fe43Sopenharmony_ci#define osal_module_platform_driver(platform_driver) \ 5831bd4fe43Sopenharmony_ci osal_module_driver(platform_driver, osal_platform_driver_register, \ 5841bd4fe43Sopenharmony_ci osal_platform_driver_unregister) 5851bd4fe43Sopenharmony_ci 5861bd4fe43Sopenharmony_ci/* mmz apis */ 5871bd4fe43Sopenharmony_ciextern unsigned long long cmpi_mmz_malloc(const char *mmz_name, const char *buf_name, unsigned long ul_size); 5881bd4fe43Sopenharmony_ciextern void cmpi_mmz_free(unsigned long long phy_addr, void *vir_addr); 5891bd4fe43Sopenharmony_ciextern int cmpi_mmz_malloc_nocache(const char *cp_mmz_name, const char *buf_name, 5901bd4fe43Sopenharmony_ci unsigned long long *phy_addr, void **pp_vir_addr, unsigned long ul_len); 5911bd4fe43Sopenharmony_ciextern int cmpi_mmz_malloc_cached(const char *cp_mmz_name, const char *buf_name, 5921bd4fe43Sopenharmony_ci unsigned long long *phy_addr, void **pp_vir_addr, unsigned long ul_len); 5931bd4fe43Sopenharmony_ciextern int cmpi_check_mmz_phy_addr(unsigned long long phy_addr, unsigned int len); 5941bd4fe43Sopenharmony_ci 5951bd4fe43Sopenharmony_civoid *cmpi_remap_cached(unsigned long long phy_addr, unsigned long ul_size); 5961bd4fe43Sopenharmony_civoid *cmpi_remap_nocache(unsigned long long phy_addr, unsigned long ul_size); 5971bd4fe43Sopenharmony_civoid cmpi_unmap(void *virt_addr); 5981bd4fe43Sopenharmony_ci 5991bd4fe43Sopenharmony_ci#ifdef CONFIG_USER_SPACE 6001bd4fe43Sopenharmony_ciextern int cmpi_get_fd(void); 6011bd4fe43Sopenharmony_ciextern void cmpi_set_fd(int fd); 6021bd4fe43Sopenharmony_ci#endif 6031bd4fe43Sopenharmony_ci 6041bd4fe43Sopenharmony_ci#ifndef IORESOURCE_MEM 6051bd4fe43Sopenharmony_ci#define IORESOURCE_MEM 0x00000200 6061bd4fe43Sopenharmony_ci#endif 6071bd4fe43Sopenharmony_ci 6081bd4fe43Sopenharmony_ci#endif 609