⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bus.h

📁 国产CPU-龙芯(loongson)BIOS源代码
💻 H
📖 第 1 页 / 共 3 页
字号:
 * described by tag/handle/offset. */#define	bus_space_write_1(t, h, o, v)	do {				\	if ((t) == I386_BUS_SPACE_IO)					\		outb((h) + (o), (v));					\	else								\		((void)(*(volatile u_int8_t *)((h) + (o)) = (v)));	\} while (0)#define	bus_space_write_2(t, h, o, v)	do {				\	if ((t) == I386_BUS_SPACE_IO)					\		outw((h) + (o), (v));					\	else								\		((void)(*(volatile u_int16_t *)((h) + (o)) = (v)));	\} while (0)#define	bus_space_write_4(t, h, o, v)	do {				\	if ((t) == I386_BUS_SPACE_IO)					\		outl((h) + (o), (v));					\	else								\		((void)(*(volatile u_int32_t *)((h) + (o)) = (v)));	\} while (0)#if 0	/* Cause a link error for bus_space_write_8 */#define	bus_space_write_8	!!! bus_space_write_8 not implemented !!!#endif/* *	void bus_space_write_multi_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    const u_intN_t *addr, size_t count); * * Write `count' 1, 2, 4, or 8 byte quantities from the buffer * provided to bus space described by tag/handle/offset. */#define	bus_space_write_multi_1(t, h, o, a, cnt) do {			\	if ((t) == I386_BUS_SPACE_IO) {					\		outsb((h) + (o), (a), (cnt));				\	} else {const void *_addr=(a); int _cnt=(cnt);			\		__asm __volatile("					\			cld					;	\		1:	lodsb					;	\			movb %%al,(%2)				;	\			loop 1b"				:	\		    "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o))	:	\		    "%eax", "memory", "cc");				\	}								\} while (0)#define bus_space_write_multi_2(t, h, o, a, cnt) do {			\	if ((t) == I386_BUS_SPACE_IO) {					\		outsw((h) + (o), (a), (cnt));				\	} else {const void *_addr=(a); int _cnt=(cnt);			\		__asm __volatile("					\			cld					;	\		1:	lodsw					;	\			movw %%ax,(%2)				;	\			loop 1b"				:	\		    "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o))	:	\		    "%eax", "memory", "cc");				\	}								\} while (0)#define bus_space_write_multi_4(t, h, o, a, cnt) do {			\	if ((t) == I386_BUS_SPACE_IO) {					\		outsl((h) + (o), (a), (cnt));				\	} else {const void *_addr=(a); int _cnt=(cnt);			\		__asm __volatile("					\			cld					;	\		1:	lodsl					;	\			movl %%eax,(%2)				;	\			loop 1b"				:	\		    "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o))	:	\		    "%eax", "memory", "cc");				\	}								\} while (0)#if 0	/* Cause a link error for bus_space_write_multi_8 */#define	bus_space_write_multi_8(t, h, o, a, c)				\			!!! bus_space_write_multi_8 unimplemented !!!#endif/* *	void bus_space_write_raw_multi_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    const u_int8_t *addr, size_t count); * * Write `count' bytes in 2, 4 or 8 byte wide quantities from the buffer * provided to bus space described by tag/handle/offset.  The buffer * must have proper alignment for the N byte wide entities.  Furthermore * possible byte-swapping should be done by these functions. */#define	bus_space_write_raw_multi_2(t, h, o, a, c) \    bus_space_write_multi_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)#define	bus_space_write_raw_multi_4(t, h, o, a, c) \    bus_space_write_multi_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)#if 0	/* Cause a link error for bus_space_write_raw_multi_8 */#define	bus_space_write_raw_multi_8 \    !!! bus_space_write_raw_multi_8 unimplemented !!!#endif/* *	void bus_space_write_region_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    const u_intN_t *addr, size_t count); * * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided * to bus space described by tag/handle starting at `offset'. */#define	bus_space_write_region_1(t, h, o, a, cnt) do {			\	int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt);	\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	lodsb					;	\			outb %%al,%w0				;	\			incl %0					;	\			loop 1b"				:	\		    "+d" (_port), "+S" (_addr), "+c" (_cnt)	::	\		    "%eax", "memory", "cc");				\	} else								\		i386_space_copy(_addr, _port, 1, _cnt);			\} while (0)#define	bus_space_write_region_2(t, h, o, a, cnt) do {			\	int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt);	\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	lodsw					;	\			outw %%ax,%w0				;	\			addl $2,%0				;	\			loop 1b"				:	\		    "+d" (_port), "+S" (_addr), "+c" (_cnt)	::	\		    "%eax", "memory", "cc");				\	} else								\		i386_space_copy(_addr, _port, 2, _cnt);			\} while (0)#define	bus_space_write_region_4(t, h, o, a, cnt) do {			\	int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt);	\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	lodsl					;	\			outl %%eax,%w0				;	\			addl $4,%0				;	\			loop 1b"				:	\		    "+d" (_port), "+S" (_addr), "+c" (_cnt)	::	\		    "%eax", "memory", "cc");				\	} else								\		i386_space_copy(_addr, _port, 4, _cnt);			\} while (0)#if 0	/* Cause a link error for bus_space_write_region_8 */#define	bus_space_write_region_8					\			!!! bus_space_write_region_8 unimplemented !!!#endif/* *	void bus_space_write_raw_region_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    const u_int8_t *addr, size_t count); * * Write `count' bytes in 2, 4 or 8 byte wide quantities to bus space * described by tag/handle and starting at `offset' from the * buffer provided.  The buffer must have proper alignment for the N byte * wide entities.  Furthermore possible byte-swapping should be done by * these functions. */#define	bus_space_write_raw_region_2(t, h, o, a, c) \    bus_space_write_region_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)#define	bus_space_write_raw_region_4(t, h, o, a, c) \    bus_space_write_region_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)#if 0	/* Cause a link error for bus_space_write_raw_region_8 */#define	bus_space_write_raw_region_8 \    !!! bus_space_write_raw_region_8 unimplemented !!!#endif/* *	void bus_space_set_multi_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    u_intN_t val, size_t count); * * Write the 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle/offset `count' times. */#define	bus_space_set_multi_1(t, h, o, v, cnt) do {			\	int _cnt=(cnt);							\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	outb %b2, %w1				;	\			loop 1b"				:	\		    "+c" (_cnt) : "d" ((h) + (o)), "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\		1:	movb %b2, (%1)				;	\			loop 1b"				:	\		    "+c" (_cnt) : "D" ((h) + (o)), "a" ((v))	:	\		    "cc", "memory");					\	}								\} while (0)#define	bus_space_set_multi_2(t, h, o, v, cnt) do {			\	int _cnt=(cnt);							\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	outw %w2, %w1				;	\			loop 1b"				:	\		    "+c" (_cnt) : "d" ((h) + (o)), "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\		1:	movw %w2, (%1)				;	\			loop 1b"				:	\		    "+c" (_cnt) : "D" ((h) + (o)), "a" ((v))	:	\		    "cc", "memory");					\	}								\} while (0)#define	bus_space_set_multi_4(t, h, o, v, cnt) do {			\	int _cnt=(cnt);							\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\			cld					;	\		1:	outl %2,%w1				;	\			loop 1b"				:	\		    "+c" (_cnt) : "d" ((h) + (o)), "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\		1:	movl %2,(%1)				;	\			loop 1b"				:	\		    "+c" (_cnt) : "D" ((h) + (o)), "a" ((v))	:	\		    "cc", "memory");					\	}								\} while (0)#if 0	/* Cause a link error for bus_space_set_multi_8 */#define	bus_space_set_multi_8					\			!!! bus_space_set_multi_8 unimplemented !!!#endif/* *	void bus_space_set_region_N(bus_space_tag_t tag, *	    bus_space_handle_t bsh, bus_size_t offset, *	    u_intN_t val, size_t count); * * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle starting at `offset'. */#define	bus_space_set_region_1(t, h, o, v, cnt) do {			\	int _port = (h)+(o); int _cnt = (cnt);				\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\		1:	outb %%al,%w0				;	\			incl %0					;	\			loop 1b"				:	\		    "+d" (_port), "+c" (_cnt) : "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\			repne					;	\			stosb"					:	\		    "+D" (_port), "+c" (_cnt) : "a" ((v))	:	\		    "memory", "cc");					\	}								\} while (0)#define	bus_space_set_region_2(t, h, o, v, cnt) do {			\	int _port = (h)+(o); int _cnt = (cnt);				\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\		1:	outw %%ax,%w0				;	\			addl $2, %0				;	\			loop 1b"				:	\		    "+d" (_port), "+c" (_cnt) : "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\			repne					;	\			stosw"					:	\		    "+D" (_port), "+c" (_cnt) : "a" ((v))	:	\		    "memory", "cc");					\	}								\} while (0)#define	bus_space_set_region_4(t, h, o, v, cnt) do {			\	int _port = (h)+(o); int _cnt = (cnt);				\	if ((t) == I386_BUS_SPACE_IO) {					\		__asm __volatile("					\		1:	outl %%eax,%w0				;	\			addl $4, %0				;	\			loop 1b"				:	\		    "+d" (_port), "+c" (_cnt) : "a" ((v))	:	\		    "cc");						\	} else {							\		__asm __volatile("					\			cld					;	\			repne					;	\

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -