18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _H8300_SEGMENT_H 38c2ecf20Sopenharmony_ci#define _H8300_SEGMENT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* define constants */ 68c2ecf20Sopenharmony_ci#define USER_DATA (1) 78c2ecf20Sopenharmony_ci#ifndef __USER_DS 88c2ecf20Sopenharmony_ci#define __USER_DS (USER_DATA) 98c2ecf20Sopenharmony_ci#endif 108c2ecf20Sopenharmony_ci#define USER_PROGRAM (2) 118c2ecf20Sopenharmony_ci#define SUPER_DATA (3) 128c2ecf20Sopenharmony_ci#ifndef __KERNEL_DS 138c2ecf20Sopenharmony_ci#define __KERNEL_DS (SUPER_DATA) 148c2ecf20Sopenharmony_ci#endif 158c2ecf20Sopenharmony_ci#define SUPER_PROGRAM (4) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_citypedef struct { 208c2ecf20Sopenharmony_ci unsigned long seg; 218c2ecf20Sopenharmony_ci} mm_segment_t; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 248c2ecf20Sopenharmony_ci#define USER_DS MAKE_MM_SEG(__USER_DS) 258c2ecf20Sopenharmony_ci#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS) 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * Get/set the SFC/DFC registers for MOVES instructions 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic inline mm_segment_t get_fs(void) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci return USER_DS; 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#endif /* _H8300_SEGMENT_H */ 41