1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* bootstd.h: Bootloader system call interface
4 * (c) 1999, Rt-Control, Inc.
10 #define NR_BSC 21 /* last used bootloader system call */
12 #define __BN_reset 0 /* reset and start the bootloader */
13 #define __BN_test 1 /* tests the system call interface */
14 #define __BN_exec 2 /* executes a bootloader image */
15 #define __BN_exit 3 /* terminates a bootloader image */
16 #define __BN_program 4 /* program FLASH from a chain */
17 #define __BN_erase 5 /* erase sector(s) of FLASH */
22 #define __BN_mmap 10 /* map a file descriptor into memory */
23 #define __BN_munmap 11 /* remove a file to memory mapping */
24 #define __BN_gethwaddr 12 /* get the hardware address of my interfaces */
25 #define __BN_getserialnum 13 /* get the serial number of this board */
26 #define __BN_getbenv 14 /* get a bootloader envvar */
27 #define __BN_setbenv 15 /* get a bootloader envvar */
28 #define __BN_setpmask 16 /* set the protection mask */
29 #define __BN_readenv 17 /* read environment variables */
30 #define __BN_flash_chattr_range 18
31 #define __BN_flash_erase_range 19
32 #define __BN_flash_write_range 20
34 /* Calling conventions compatible to (uC)linux/68k
35 * We use similar macros to call into the bootloader as for uClinux
38 #define __bsc_return(type, res) \
40 if ((unsigned long)(res) >= (unsigned long)(-64)) { \
41 /* let errno be a function, preserve res in %d0 */ \
49 #define _bsc0(type,name) \
52 register long __res __asm__ ("%d0") = __BN_##name; \
53 __asm__ __volatile__ ("trap #2" \
57 __bsc_return(type,__res); \
60 #define _bsc1(type,name,atype,a) \
63 register long __res __asm__ ("%d0") = __BN_##name; \
64 register long __a __asm__ ("%d1") = (long)a; \
65 __asm__ __volatile__ ("trap #2" \
67 : "0" (__res), "d" (__a) \
69 __bsc_return(type,__res); \
72 #define _bsc2(type,name,atype,a,btype,b) \
73 type name(atype a, btype b) \
75 register long __res __asm__ ("%d0") = __BN_##name; \
76 register long __a __asm__ ("%d1") = (long)a; \
77 register long __b __asm__ ("%d2") = (long)b; \
78 __asm__ __volatile__ ("trap #2" \
80 : "0" (__res), "d" (__a), "d" (__b) \
82 __bsc_return(type,__res); \
85 #define _bsc3(type,name,atype,a,btype,b,ctype,c) \
86 type name(atype a, btype b, ctype c) \
88 register long __res __asm__ ("%d0") = __BN_##name; \
89 register long __a __asm__ ("%d1") = (long)a; \
90 register long __b __asm__ ("%d2") = (long)b; \
91 register long __c __asm__ ("%d3") = (long)c; \
92 __asm__ __volatile__ ("trap #2" \
94 : "0" (__res), "d" (__a), "d" (__b), \
97 __bsc_return(type,__res); \
100 #define _bsc4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
101 type name(atype a, btype b, ctype c, dtype d) \
103 register long __res __asm__ ("%d0") = __BN_##name; \
104 register long __a __asm__ ("%d1") = (long)a; \
105 register long __b __asm__ ("%d2") = (long)b; \
106 register long __c __asm__ ("%d3") = (long)c; \
107 register long __d __asm__ ("%d4") = (long)d; \
108 __asm__ __volatile__ ("trap #2" \
110 : "0" (__res), "d" (__a), "d" (__b), \
111 "d" (__c), "d" (__d) \
113 __bsc_return(type,__res); \
116 #define _bsc5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
117 type name(atype a, btype b, ctype c, dtype d, etype e) \
119 register long __res __asm__ ("%d0") = __BN_##name; \
120 register long __a __asm__ ("%d1") = (long)a; \
121 register long __b __asm__ ("%d2") = (long)b; \
122 register long __c __asm__ ("%d3") = (long)c; \
123 register long __d __asm__ ("%d4") = (long)d; \
124 register long __e __asm__ ("%d5") = (long)e; \
125 __asm__ __volatile__ ("trap #2" \
127 : "0" (__res), "d" (__a), "d" (__b), \
128 "d" (__c), "d" (__d), "d" (__e) \
130 __bsc_return(type,__res); \
133 #endif /* __BOOTSTD_H__ */