all: Update reserved function names

Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h
index 76be796..40c40c2 100644
--- a/kernel/include/kernel_internal.h
+++ b/kernel/include/kernel_internal.h
@@ -25,27 +25,27 @@
 
 /* Early boot functions */
 
-void _bss_zero(void);
+void z_bss_zero(void);
 #ifdef CONFIG_XIP
-void _data_copy(void);
+void z_data_copy(void);
 #else
-static inline void _data_copy(void)
+static inline void z_data_copy(void)
 {
 	/* Do nothing */
 }
 #endif
-FUNC_NORETURN void _Cstart(void);
+FUNC_NORETURN void z_cstart(void);
 
-extern FUNC_NORETURN void _thread_entry(k_thread_entry_t entry,
+extern FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry,
 			  void *p1, void *p2, void *p3);
 
-/* Implemented by architectures. Only called from _setup_new_thread. */
-extern void _new_thread(struct k_thread *thread, k_thread_stack_t *pStack,
+/* Implemented by architectures. Only called from z_setup_new_thread. */
+extern void z_new_thread(struct k_thread *thread, k_thread_stack_t *pStack,
 			size_t stackSize, k_thread_entry_t entry,
 			void *p1, void *p2, void *p3,
 			int prio, unsigned int options);
 
-extern void _setup_new_thread(struct k_thread *new_thread,
+extern void z_setup_new_thread(struct k_thread *new_thread,
 			      k_thread_stack_t *stack, size_t stack_size,
 			      k_thread_entry_t entry,
 			      void *p1, void *p2, void *p3,
@@ -65,7 +65,7 @@
  *
  * @return Max number of free regions, or -1 if there is no limit
  */
-extern int _arch_mem_domain_max_partitions_get(void);
+extern int z_arch_mem_domain_max_partitions_get(void);
 
 /**
  * @brief Configure the memory domain of the thread.
@@ -77,7 +77,7 @@
  *
  * @param thread Thread which needs to be configured.
  */
-extern void _arch_mem_domain_configure(struct k_thread *thread);
+extern void z_arch_mem_domain_configure(struct k_thread *thread);
 
 /**
  * @brief Remove a partition from the memory domain
@@ -90,8 +90,8 @@
  * @param domain The memory domain structure
  * @param partition_id The partition that needs to be deleted
  */
-extern void _arch_mem_domain_partition_remove(struct k_mem_domain *domain,
-					      u32_t partition_id);
+extern void z_arch_mem_domain_partition_remove(struct k_mem_domain *domain,
+					       u32_t partition_id);
 
 /**
  * @brief Remove a partition from the memory domain
@@ -105,7 +105,7 @@
  * @param partition_id The partition that needs to be added
  */
 extern void _arch_mem_domain_partition_add(struct k_mem_domain *domain,
-					   u32_t partition_id);
+					    u32_t partition_id);
 
 /**
  * @brief Remove the memory domain
@@ -116,7 +116,7 @@
  *
  * @param domain The memory domain structure which needs to be deleted.
  */
-extern void _arch_mem_domain_destroy(struct k_mem_domain *domain);
+extern void z_arch_mem_domain_destroy(struct k_mem_domain *domain);
 
 /**
  * @brief Check memory region permissions
@@ -132,7 +132,7 @@
  *
  * @return nonzero if the permissions don't match.
  */
-extern int _arch_buffer_validate(void *addr, size_t size, int write);
+extern int z_arch_buffer_validate(void *addr, size_t size, int write);
 
 /**
  * Perform a one-way transition from supervisor to kernel mode.
@@ -143,7 +143,7 @@
  * - Set up any kernel stack region for the CPU to use during privilege
  *   elevation
  * - Put the CPU in whatever its equivalent of user mode is
- * - Transfer execution to _new_thread() passing along all the supplied
+ * - Transfer execution to z_new_thread() passing along all the supplied
  *   arguments, in user mode.
  *
  * @param Entry point to start executing as a user thread
@@ -152,7 +152,7 @@
  * @param p3 3rd parameter to user thread
  */
 extern FUNC_NORETURN
-void _arch_user_mode_enter(k_thread_entry_t user_entry, void *p1, void *p2,
+void z_arch_user_mode_enter(k_thread_entry_t user_entry, void *p1, void *p2,
 			   void *p3);
 
 
@@ -170,7 +170,7 @@
  *            to _k_syscall_handler_t functions and its contents are completely
  *            architecture specific.
  */
-extern FUNC_NORETURN void _arch_syscall_oops(void *ssf);
+extern FUNC_NORETURN void z_arch_syscall_oops(void *ssf);
 
 /**
  * @brief Safely take the length of a potentially bad string
@@ -190,7 +190,7 @@
  * @brief Zero out BSS sections for application shared memory
  *
  * This isn't handled by any platform bss zeroing, and is called from
- * _Cstart() if userspace is enabled.
+ * z_cstart() if userspace is enabled.
  */
 extern void z_app_shmem_bss_zero(void);
 #endif /* CONFIG_USERSPACE */
@@ -210,15 +210,15 @@
 
 /* set and clear essential thread flag */
 
-extern void _thread_essential_set(void);
-extern void _thread_essential_clear(void);
+extern void z_thread_essential_set(void);
+extern void z_thread_essential_clear(void);
 
 /* clean up when a thread is aborted */
 
 #if defined(CONFIG_THREAD_MONITOR)
-extern void _thread_monitor_exit(struct k_thread *thread);
+extern void z_thread_monitor_exit(struct k_thread *thread);
 #else
-#define _thread_monitor_exit(thread) \
+#define z_thread_monitor_exit(thread) \
 	do {/* nothing */    \
 	} while (false)
 #endif /* CONFIG_THREAD_MONITOR */