setos

拙OS
Log | Files | Refs | LICENSE

commit 51649e44e038c92b3ad3b2e0c2001a5e56998c22
parent 29d87c49217f5bd6a8c4841fe5c965d26e2f0e06
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed,  1 May 2024 07:56:52 +0900

ignore endianness for now

Diffstat:
Msys/include/libc.h | 7-------
Msys/src/Makefile | 6++----
Msys/src/kernel/amd64/pci.c | 8++++----
Dsys/src/libc/endian.c | 59-----------------------------------------------------------
4 files changed, 6 insertions(+), 74 deletions(-)

diff --git a/sys/include/libc.h b/sys/include/libc.h @@ -33,13 +33,6 @@ extern Memmap memmap; void *malloc(uintptr); void *memset(void *s, int c, uintptr n); -uint16 endian_little_to_native16(uint16); -uint16 endian_native_to_little16(uint16); -uint32 endian_little_to_native32(uint32); -uint32 endian_native_to_little32(uint32); -uint64 endian_little_to_native64(uint64); -uint64 endian_native_to_little64(uint64); - /* typedef char *va_list; // ABI is different from plan9. diff --git a/sys/src/Makefile b/sys/src/Makefile @@ -64,14 +64,12 @@ kernel/$(ARCH)/machine.o: kernel/$(ARCH)/machine.s kernel/xhc.o: kernel/xhc.c ../include/xhc.h $(CC) $(CFLAGS) -c -o $@ kernel/xhc.c -../lib/libc.a: libc/strcpy.o libc/memset.o libc/endian.o ../lib - ar rcs $@ libc/strcpy.o libc/memset.o libc/endian.o +../lib/libc.a: libc/strcpy.o libc/memset.o ../lib + ar rcs $@ libc/strcpy.o libc/memset.o libc/strcpy.o: libc/strcpy.c ../include/libc.h $(CC) $(CFLAGS) -c -o $@ libc/strcpy.c libc/memset.o: libc/memset.c ../include/libc.h $(CC) $(CFLAGS) -c -o $@ libc/memset.c -libc/endian.o: libc/endian.c ../include/libc.h - $(CC) $(CFLAGS) -c -o $@ libc/endian.c ../lib: mkdir -p ../lib diff --git a/sys/src/kernel/amd64/pci.c b/sys/src/kernel/amd64/pci.c @@ -18,8 +18,8 @@ pci_config_read16(uint8 bus, uint8 dev, uint8 func, uint8 offset) (uint32) (dev&0x1f) << 11 | (uint32) (func&3) << 8 | (offset&0xfc); // the least 2 bits should be 0. - io_out32(pci_config_address, endian_native_to_little32(addr)); - tmp = endian_little_to_native32(io_in32(pci_config_data)); + io_out32(pci_config_address, addr); + tmp = io_in32(pci_config_data); return (tmp >> (offset&2)*8) & 0xffff; } @@ -32,6 +32,6 @@ pci_config_read32(uint8 bus, uint8 dev, uint8 func, uint8 offset) (uint32) (dev&0x1f) << 11 | (uint32) (func&3) << 8 | (offset&0xfc); // the least 2 bits should be 0. - io_out32(pci_config_address, endian_native_to_little32(addr)); - return endian_little_to_native32(io_in32(pci_config_data)); + io_out32(pci_config_address, addr); + return io_in32(pci_config_data); } diff --git a/sys/src/libc/endian.c b/sys/src/libc/endian.c @@ -1,59 +0,0 @@ -#include <libc.h> - -uint16 -endian_little_to_native16(uint16 n) -{ - uint8 *m = (uint8 *) &n; - return (uint16) m[0] | (uint16) m[1] << 8; -} - -uint16 -endian_native_to_little16(uint16 n) -{ - uint8 m[2]; - m[0] = (uint8) n&0x000000ff; - m[1] = (uint8) ((n&0x0000ff00) >> 8); - return *(uint16 *)m; -} - -uint32 -endian_little_to_native32(uint32 n) -{ - uint8 *m = (uint8 *) &n; - return (uint32) m[0] | (uint32) m[1] << 8 | (uint32) m[2] << 16 | (uint32) m[3] << 24; -} - -uint32 -endian_native_to_little32(uint32 n) -{ - uint8 m[4]; - m[0] = (uint8) n&0x000000ff; - m[1] = (uint8) ((n&0x0000ff00) >> 8); - m[2] = (uint8) ((n&0x00ff0000) >> 16); - m[3] = (uint8) ((n&0xff000000) >> 24); - return *(uint32 *)m; -} - -uint64 -endian_little_to_native64(uint64 n) -{ - uint8 *m = (uint8 *) &n; - return (uint64) m[0] | (uint64) m[1] << 8 | (uint64) m[2] << 16 | - (uint64) m[3] << 24 | (uint64) m[4] << 32 | (uint64) m[5] << 40 | - (uint64) m[6] << 48 | (uint64) m[7] << 56; -} - -uint64 -endian_native_to_little64(uint64 n) -{ - uint8 m[8]; - m[0] = (uint8) n&0x00000000000000ff; - m[1] = (uint8) ((n&0x000000000000ff00) >> 8); - m[2] = (uint8) ((n&0x0000000000ff0000) >> 16); - m[3] = (uint8) ((n&0x00000000ff000000) >> 24); - m[4] = (uint8) ((n&0x000000ff00000000) >> 32); - m[5] = (uint8) ((n&0x0000ff0000000000) >> 40); - m[6] = (uint8) ((n&0x00ff000000000000) >> 48); - m[7] = (uint8) ((n&0xff00000000000000) >> 56); - return *(uint64 *)m; -}