1 /* kernel_thread.S: kernel thread creation
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/linkage.h>
13 #include <linux/kern_levels.h>
14 #include <asm/unistd.h>
16 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
20 .asciz KERN_ERR "failed to create kernel thread: error=%d\n"
25 ###############################################################################
27 # Create a kernel thread
29 # int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
31 ###############################################################################
33 .type kernel_thread,@function
38 # start by forking the current process, but with shared VM
39 setlos.p #__NR_clone,gr7 ; syscall number
40 ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
41 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
43 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
44 setlos #0,gr11 ; fourth syscall arg [child_tidptr]
47 andcc gr8,gr8,gr0,icc0
48 addcc.p gr8,gr7,gr0,icc1
50 bc icc1,#0,kernel_thread_error
52 # now invoke the work function
56 # and finally exit the thread
57 setlos #__NR_exit,gr7 ; syscall number
67 sethi.p %hi(kernel_thread_emsg),gr8
68 setlo %lo(kernel_thread_emsg),gr8
77 .size kernel_thread,.-kernel_thread