uaccess-tt.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #ifndef __TT_UACCESS_H
  6. #define __TT_UACCESS_H
  7. #include "linux/string.h"
  8. #include "linux/sched.h"
  9. #include "asm/processor.h"
  10. #include "asm/errno.h"
  11. #include "asm/current.h"
  12. #include "asm/a.out.h"
  13. #include "uml_uaccess.h"
  14. #define ABOVE_KMEM (16 * 1024 * 1024)
  15. extern unsigned long end_vm;
  16. extern unsigned long uml_physmem;
  17. #define under_task_size(addr, size) \
  18. (((unsigned long) (addr) < TASK_SIZE) && \
  19. (((unsigned long) (addr) + (size)) < TASK_SIZE))
  20. #define is_stack(addr, size) \
  21. (((unsigned long) (addr) < STACK_TOP) && \
  22. ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
  23. (((unsigned long) (addr) + (size)) <= STACK_TOP))
  24. #define access_ok_tt(type, addr, size) \
  25. ((type == VERIFY_READ) || (segment_eq(get_fs(), KERNEL_DS)) || \
  26. (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
  27. (under_task_size(addr, size) || is_stack(addr, size))))
  28. static inline int verify_area_tt(int type, const void * addr,
  29. unsigned long size)
  30. {
  31. return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
  32. }
  33. extern unsigned long get_fault_addr(void);
  34. extern int __do_copy_from_user(void *to, const void *from, int n,
  35. void **fault_addr, void **fault_catcher);
  36. extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
  37. void **fault_addr, void **fault_catcher);
  38. extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
  39. void **fault_catcher);
  40. extern int __do_strnlen_user(const char *str, unsigned long n,
  41. void **fault_addr, void **fault_catcher);
  42. extern int copy_from_user_tt(void *to, const void *from, int n);
  43. extern int copy_to_user_tt(void *to, const void *from, int n);
  44. extern int strncpy_from_user_tt(char *dst, const char *src, int count);
  45. extern int __clear_user_tt(void *mem, int len);
  46. extern int clear_user_tt(void *mem, int len);
  47. extern int strnlen_user_tt(const void *str, int len);
  48. #endif
  49. /*
  50. * Overrides for Emacs so that we follow Linus's tabbing style.
  51. * Emacs will notice this stuff at the end of the file and automatically
  52. * adjust the settings for this buffer only. This must remain at the end
  53. * of the file.
  54. * ---------------------------------------------------------------------------
  55. * Local variables:
  56. * c-file-style: "linux"
  57. * End:
  58. */