xref: /linux/arch/m68k/include/asm/bootstd.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* bootstd.h:  Bootloader system call interface
3  *
4  * (c) 1999, Rt-Control, Inc.
5  */
6 
7 #ifndef __BOOTSTD_H__
8 #define __BOOTSTD_H__
9 
10 #define NR_BSC 21            /* last used bootloader system call */
11 
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 */
18 #define __BN_open         6
19 #define __BN_write        7
20 #define __BN_read         8
21 #define __BN_close        9
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
33 
34 /* Calling conventions compatible to (uC)linux/68k
35  * We use similar macros to call into the bootloader as for uClinux
36  */
37 
38 #define __bsc_return(type, res) \
39 do { \
40    if ((unsigned long)(res) >= (unsigned long)(-64)) { \
41       /* let errno be a function, preserve res in %d0 */ \
42       int __err = -(res); \
43       errno = __err; \
44       res = -1; \
45    } \
46    return (type)(res); \
47 } while (0)
48 
49 #define _bsc0(type,name) \
50 type name(void) \
51 { \
52    register long __res __asm__ ("%d0") = __BN_##name; \
53    __asm__ __volatile__ ("trap #2" \
54                          : "=g" (__res) \
55                          : "0" (__res) \
56                          ); \
57    __bsc_return(type,__res); \
58 }
59 
60 #define _bsc1(type,name,atype,a) \
61 type name(atype a) \
62 { \
63    register long __res __asm__ ("%d0") = __BN_##name; \
64    register long __a __asm__ ("%d1") = (long)a; \
65    __asm__ __volatile__ ("trap #2" \
66                          : "=g" (__res) \
67                          : "0" (__res), "d" (__a) \
68                          ); \
69    __bsc_return(type,__res); \
70 }
71 
72 #define _bsc2(type,name,atype,a,btype,b) \
73 type name(atype a, btype b) \
74 { \
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" \
79                          : "=g" (__res) \
80                          : "0" (__res), "d" (__a), "d" (__b) \
81                          ); \
82    __bsc_return(type,__res); \
83 }
84 
85 #define _bsc3(type,name,atype,a,btype,b,ctype,c) \
86 type name(atype a, btype b, ctype c) \
87 { \
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" \
93                          : "=g" (__res) \
94                          : "0" (__res), "d" (__a), "d" (__b), \
95                            "d" (__c) \
96                          ); \
97    __bsc_return(type,__res); \
98 }
99 
100 #define _bsc4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
101 type name(atype a, btype b, ctype c, dtype d) \
102 { \
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" \
109                          : "=g" (__res) \
110                          : "0" (__res), "d" (__a), "d" (__b), \
111                            "d" (__c), "d" (__d) \
112                          ); \
113    __bsc_return(type,__res); \
114 }
115 
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) \
118 { \
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" \
126                          : "=g" (__res) \
127                          : "0" (__res), "d" (__a), "d" (__b), \
128                            "d" (__c), "d" (__d), "d" (__e) \
129                          ); \
130    __bsc_return(type,__res); \
131 }
132 
133 #endif /* __BOOTSTD_H__ */
134