diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
| commit | 1c8414d3348c55fcf132839a04fdedec5efaacbe (patch) | |
| tree | 5c7386fae0504a798801e0b34b588f4177ba67c1 | |
| parent | d7e35959ebb6b1dd892a99f23c2a7f23c0f99041 (diff) | |
dev: refactor codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
37 files changed, 2232 insertions, 2486 deletions
diff --git a/.clang-format b/.clang-format index fb3cacb..3943f55 100644 --- a/.clang-format +++ b/.clang-format @@ -1,16 +1,29 @@ ---- -BasedOnStyle: Microsoft -AccessModifierOffset: '-4' -AlignAfterOpenBracket: Align -AlignConsecutiveMacros: 'true' -AlignConsecutiveAssignments: 'true' -AlignConsecutiveDeclarations: 'true' -BinPackParameters: 'false' -ColumnLimit: '0' -Language: Cpp -NamespaceIndentation: All +BasedOnStyle: Google +IndentWidth: 2 +TabWidth: 2 +UseTab: Never +ColumnLimit: 100 +DerivePointerAlignment: false PointerAlignment: Left -ReflowComments: 'true' -SortIncludes: 'false' -UseTab: Always -... +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +SortIncludes: true +IncludeBlocks: Preserve +SpaceAfterCStyleCast: true +SpaceBeforeParens: ControlStatements +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +BreakBeforeBraces: Attach +ConstructorInitializerAllOnOneLineOrOnePerLine: true +Cpp11BracedListStyle: true +NamespaceIndentation: Inner +ReflowComments: true +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignTrailingComments: true +FixNamespaceComments: true +IncludeIsMainRegex: '(Test)?$' +SortUsingDeclarations: true diff --git a/lib/30pin.h b/lib/30pin.h index 6de5981..68691b9 100644 --- a/lib/30pin.h +++ b/lib/30pin.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -23,23 +23,21 @@ /// @param kind kind of packet we deal with. /// @param buffer the data of the packet. /// @param eop end of packet data. -struct _cb_tpin_recovery_packet -{ - uint8_t mag[CP_30PIN_MAG_LEN]; - uint8_t kind; - uint8_t buffer[CB_30PIN_BUFFER_LEN]; - uint8_t eop[CB_30PIN_EOP_LEN]; +struct _cb_tpin_recovery_packet { + uint8_t mag[CP_30PIN_MAG_LEN]; + uint8_t kind; + uint8_t buffer[CB_30PIN_BUFFER_LEN]; + uint8_t eop[CB_30PIN_EOP_LEN]; }; /// @brief 30pin recovery packet kinds. -enum -{ - TPIN_RECOVERY_PACKET_KIND_UNKNOWN = 0, - TPIN_RECOVERY_PACKET_KIND_BOOT = 1, - TPIN_RECOVERY_PACKET_KIND_DATA = 2, - TPIN_RECOVERY_PACKET_KIND_EOP = 3, - TPIN_RECOVERY_PACKET_KIND_EOP_ACK = 4, - TPIN_RECOVERY_PACKET_KIND_EOP_NACK = 5, +enum { + TPIN_RECOVERY_PACKET_KIND_UNKNOWN = 0, + TPIN_RECOVERY_PACKET_KIND_BOOT = 1, + TPIN_RECOVERY_PACKET_KIND_DATA = 2, + TPIN_RECOVERY_PACKET_KIND_EOP = 3, + TPIN_RECOVERY_PACKET_KIND_EOP_ACK = 4, + TPIN_RECOVERY_PACKET_KIND_EOP_NACK = 5, }; typedef struct _cb_tpin_recovery_packet cb_tpin_recovery_packet_t;
\ No newline at end of file @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,101 +12,98 @@ /// typedef __UINTPTR_TYPE__ uintptr_t; -typedef __UINT32_TYPE__ phys_addr_t; +typedef __UINT32_TYPE__ phys_addr_t; typedef unsigned long ulong_t; typedef unsigned long long int uint64_t; -typedef unsigned uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; +typedef unsigned uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; #ifdef __unix__ #undef __unix__ #define __unix__ 7 -#endif // !__unix__ +#endif // !__unix__ #define __mpboot__ __unix__ typedef __INTPTR_TYPE__ intptr_t; typedef __INT64_TYPE__ int64_t; -typedef int int32_t; -typedef short int16_t; -typedef char int8_t; +typedef int int32_t; +typedef short int16_t; +typedef char int8_t; -typedef void* voidptr_t; -typedef char* addr_t; +typedef void* voidptr_t; +typedef char* addr_t; typedef const char* caddr_t; typedef __UINTPTR_TYPE__ ptrtype_t; -typedef ptrtype_t size_t; +typedef ptrtype_t size_t; #define array_size(arr) (sizeof(arr[0]) / sizeof(arr)) #ifndef nil -#define nil ((voidptr_t)0) -#endif // ifndef nil +#define nil ((voidptr_t) 0) +#endif // ifndef nil #ifndef null -#define null ((voidptr_t)0) -#endif // ifndef null +#define null ((voidptr_t) 0) +#endif // ifndef null -#define __no 0 +#define __no 0 #define __yes 1 #define boolean char -#define no __no +#define no __no #define yes __yes #ifndef __cplusplus #define bool boolean #define false no #define true yes -#endif //!_cplusplus +#endif //!_cplusplus -#define CB_RESTART 0 +#define CB_RESTART 0 #define CB_SHUTDOWN 1 #define __COPYRIGHT(s) /* unused */ #ifdef __COMPILE_RISCV__ -#define CB_BOOT_ADDR (0x80020000) -#define CB_BOOT_ADDR_STR "0x80020000" +#define CB_BOOT_ADDR (0x80020000) +#define CB_BOOT_ADDR_STR "0x80020000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_UART_BASE 0x10000000 -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_UART_BASE 0x10000000 +#define CB_FLASH_BASE_ADDR 0x08000000 #define cb_sync_synchronize() __sync_synchronize() #elif defined(__COMPILE_POWERPC__) -#define CB_UART_BASE 0x10000000 -#define CB_BOOT_ADDR 0x1030000 -#define CB_BOOT_ADDR_STR "0x1030000" +#define CB_UART_BASE 0x10000000 +#define CB_BOOT_ADDR 0x1030000 +#define CB_BOOT_ADDR_STR "0x1030000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_FLASH_BASE_ADDR 0x08000000 #define cb_sync_synchronize() __sync_synchronize() #elif defined(__COMPILE_ARM64__) -#define CB_UART_BASE 0x09000000 -#define CB_BOOT_ADDR 0x1030000 -#define CB_BOOT_ADDR_STR "0x1030000" +#define CB_UART_BASE 0x09000000 +#define CB_BOOT_ADDR 0x1030000 +#define CB_BOOT_ADDR_STR "0x1030000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_FLASH_BASE_ADDR 0x08000000 -static inline void __sync_synchronize(void) -{ - /// leave it as is. +static inline void __sync_synchronize(void) { + /// leave it as is. } #define cb_sync_synchronize() __sync_synchronize() -#endif // ifndef __COMPILE_POWERPC__ +#endif // ifndef __COMPILE_POWERPC__ -#define CB_BAUDRATE_TABLE \ - { \ - 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 \ - } +#define CB_BAUDRATE_TABLE \ + { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 } #define CB_STRING(s) #s @@ -115,20 +112,19 @@ static inline void __sync_synchronize(void) #define CB_BOOT_VER 0x101 -#define CB_BOOT_CALL(struct, offset) \ - volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ - proc_##offset(); +#define CB_BOOT_CALL(struct, offset) \ + volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ + proc_##offset(); /// @brief floating point representation (IEE 7554) in a C structure typedef union { - struct - { - char sign; - int32_t mantissa; - int16_t exponent; - }; - - float f; + struct { + char sign; + int32_t mantissa; + int16_t exponent; + }; + + float f; } float_t; /// \brief UTF-32 character @@ -185,12 +181,11 @@ typedef char ascii_char_t; /// @brief Linear Executable Header /// @author Amlal EL Mahrouss (Amlal EL Mahrouss) -struct __attribute__((aligned(4))) cb_boot_header -{ - const ascii_char_t h_mag[2]; // magic number - const ascii_char_t h_name[10]; // operating system name - const uint32_t h_revision; // firmware revision - const uint64_t h_start_address; // start address (master/slave(s) thread) +struct __attribute__((aligned(4))) cb_boot_header { + const ascii_char_t h_mag[2]; // magic number + const ascii_char_t h_name[10]; // operating system name + const uint32_t h_revision; // firmware revision + const uint64_t h_start_address; // start address (master/slave(s) thread) }; // EOF. diff --git a/lib/bootnet.h b/lib/bootnet.h index 81e0981..cba847c 100644 --- a/lib/bootnet.h +++ b/lib/bootnet.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,25 +8,25 @@ #include <lib/boot.h> -#define BOOTNET_INET_MAGIC "NETB" +#define BOOTNET_INET_MAGIC "NETB" #define BOOTNET_INET_MAGIC_LEN (4) #define BOOTNET_NAME_LEN (256) /// @brief Netboot Internet Header -/// Consists of 4 magic characters, and a set of fields describing the current patch that's being sent (if m_preflight = 0) +/// Consists of 4 magic characters, and a set of fields describing the current patch that's being +/// sent (if m_preflight = 0) /// @note Can be used to patch ROMs too (if m_implies_rom = 1) -typedef struct bootnet_inet_header -{ - ascii_char_t m_nb1; /// magic char 1 'N' - ascii_char_t m_nb2; /// magic char 2 'E' - ascii_char_t m_nb3; /// magic char 3 'T' - ascii_char_t m_nb4; /// magic char 4 'B' - - ascii_char_t m_patch_name[BOOTNET_NAME_LEN]; /// example: ColdChoco - int32_t m_length; /// The patch's length. - ascii_char_t m_target[BOOTNET_NAME_LEN]; /// The target file. - uint8_t m_implies_program; /// does it imply reprogramming? - uint8_t m_preflight; /// Do we just check if this endpoint exists/is valid? - uint8_t m_blob[]; +typedef struct bootnet_inet_header { + ascii_char_t m_nb1; /// magic char 1 'N' + ascii_char_t m_nb2; /// magic char 2 'E' + ascii_char_t m_nb3; /// magic char 3 'T' + ascii_char_t m_nb4; /// magic char 4 'B' + + ascii_char_t m_patch_name[BOOTNET_NAME_LEN]; /// example: ColdChoco + int32_t m_length; /// The patch's length. + ascii_char_t m_target[BOOTNET_NAME_LEN]; /// The target file. + uint8_t m_implies_program; /// does it imply reprogramming? + uint8_t m_preflight; /// Do we just check if this endpoint exists/is valid? + uint8_t m_blob[]; } bootnet_inet_header; diff --git a/lib/cxx-abi.h b/lib/cxx-abi.h index 850777f..61225fc 100644 --- a/lib/cxx-abi.h +++ b/lib/cxx-abi.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,16 +8,14 @@ #define DSO_MAX_OBJECTS (128) -struct atexit_func_entry_t -{ - void (*destructor_func)(void*); - void* obj_ptr; - void* dso_handle; +struct atexit_func_entry_t { + void (*destructor_func)(void*); + void* obj_ptr; + void* dso_handle; }; typedef unsigned uarch_t; -namespace cxxabiv1 -{ - typedef void* __guard; +namespace cxxabiv1 { +typedef void* __guard; } @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,18 +12,17 @@ struct _cb_file_descriptor; /// @brief CoreBoot file/device descriptor. /// @version 1 -typedef struct _cb_file_descriptor -{ - int32_t f_kind; - int32_t f_filesystem; - - size_t (*f_write)(void* ptr, size_t size, size_t nitems, struct _cb_file_descriptor* self); - size_t (*f_read)(void* ptr, size_t size, size_t nitems, struct _cb_file_descriptor* self); - int (*f_seek)(struct _cb_file_descriptor* self, size_t off, int whence); - int (*f_tell)(struct _cb_file_descriptor* self); - int (*f_rewind)(struct _cb_file_descriptor* self); - int (*f_eof)(struct _cb_file_descriptor* self); - int (*f_close)(struct _cb_file_descriptor* self); +typedef struct _cb_file_descriptor { + int32_t f_kind; + int32_t f_filesystem; + + size_t (*f_write)(void* ptr, size_t size, size_t nitems, struct _cb_file_descriptor* self); + size_t (*f_read)(void* ptr, size_t size, size_t nitems, struct _cb_file_descriptor* self); + int (*f_seek)(struct _cb_file_descriptor* self, size_t off, int whence); + int (*f_tell)(struct _cb_file_descriptor* self); + int (*f_rewind)(struct _cb_file_descriptor* self); + int (*f_eof)(struct _cb_file_descriptor* self); + int (*f_close)(struct _cb_file_descriptor* self); } cb_file_descriptor_t; /// @brief Grabs a new device reference. diff --git a/lib/mp-bit.h b/lib/mp-bit.h index 517f44a..869c7c3 100644 --- a/lib/mp-bit.h +++ b/lib/mp-bit.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,10 +10,10 @@ /// Name: CoreBoot Bits API. /// Purpose: Bit manip helpers. -#define cb_set_bit(X, O) X = (1 << O) | X +#define cb_set_bit(X, O) X = (1 << O) | X #define cb_clear_bit(X, O) X = ~(1 << O) & X -#define cb_toogle(X, O) X = (1 << O) ^ X -#define cb_lsb(X) X = X & -X -#define cb_msb(X) X = -(cb_lsb(X)) & X +#define cb_toogle(X, O) X = (1 << O) ^ X +#define cb_lsb(X) X = X & -X +#define cb_msb(X) X = -(cb_lsb(X)) & X -#endif // ifndef __BITMANIP_H__ +#endif // ifndef __BITMANIP_H__ diff --git a/lib/partition-map.h b/lib/partition-map.h index 37e9912..05ff83f 100644 --- a/lib/partition-map.h +++ b/lib/partition-map.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -48,12 +48,11 @@ #define EPM_REVISION (2U) /// @brief EPM GUID block. -typedef struct boot_guid -{ - uint32_t data1; - uint16_t data2; - uint16_t data3; - uint8_t data4[8]; +typedef struct boot_guid { + uint32_t data1; + uint16_t data2; + uint16_t data3; + uint8_t data4[8]; } __attribute__((packed)) boot_guid_t; /* The first 0 > 128 addresses of a disk contains these headers. */ @@ -62,41 +61,40 @@ typedef struct boot_guid * @brief The EPM partition block. * used to represent a partition inside a media. */ -struct __attribute__((packed)) part_block -{ - ascii_char_t magic[5]; - ascii_char_t name[32]; - boot_guid_t uuid; - int32_t version; - int32_t num_blocks; - int64_t lba_start; - int64_t sector_sz; - int64_t lba_end; - int16_t type; - int32_t fs_version; - ascii_char_t fs[16]; /* ffs_2 */ - ascii_char_t reserved[401]; +struct __attribute__((packed)) part_block { + ascii_char_t magic[5]; + ascii_char_t name[32]; + boot_guid_t uuid; + int32_t version; + int32_t num_blocks; + int64_t lba_start; + int64_t sector_sz; + int64_t lba_end; + int16_t type; + int32_t fs_version; + ascii_char_t fs[16]; /* ffs_2 */ + ascii_char_t reserved[401]; }; typedef struct part_block part_block_t; ///! @brief variant enum. ///! use it in the boot block version field. -enum -{ - EPM_INVALID = 0x00, - EPM_GENERIC_OS = 0xcf, - EPM_LINUX = 0x8f, - EPM_BSD = 0x9f, - EPM_ZKAOS = 0x1f, +enum { + EPM_INVALID = 0x00, + EPM_GENERIC_OS = 0xcf, + EPM_LINUX = 0x8f, + EPM_BSD = 0x9f, + EPM_ZKAOS = 0x1f, }; /// @brief check for supported filesystem. boolean cb_filesystem_exists(caddr_t fs, size_t len); /// @brief Parse EPM block from blob. -bool cb_parse_partition_block_data_at(voidptr_t blob, size_t blob_sz, size_t index, size_t* end_lba, size_t* start_lba, size_t* sector_sz); +bool cb_parse_partition_block_data_at(voidptr_t blob, size_t blob_sz, size_t index, size_t* end_lba, + size_t* start_lba, size_t* sector_sz); part_block_t* cb_parse_partition_block_at(voidptr_t blob, size_t blob_sz, size_t index); -#endif // ifndef __PARTITION_MAP_H__ +#endif // ifndef __PARTITION_MAP_H__ diff --git a/lib/pci-tree.h b/lib/pci-tree.h index 9b83da0..460b185 100644 --- a/lib/pci-tree.h +++ b/lib/pci-tree.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,28 +12,28 @@ #include <lib/boot.h> -#define PCI_INVALID_DATA_U8 ((uint8_t)~0) -#define PCI_INVALID_DATA_U16 ((uint16_t)~0) -#define PCI_INVALID_DATA_U32 ((uint32_t)~0) +#define PCI_INVALID_DATA_U8 ((uint8_t) ~0) +#define PCI_INVALID_DATA_U16 ((uint16_t) ~0) +#define PCI_INVALID_DATA_U32 ((uint32_t) ~0) -#define CB_BASE_ADDRESS (0x20008000) /* PCI base mapped in virtual memory. */ -#define CB_PCI_TREE_BASE (0x802000) /* The PCI tree base address. */ +#define CB_BASE_ADDRESS (0x20008000) /* PCI base mapped in virtual memory. */ +#define CB_PCI_TREE_BASE (0x802000) /* The PCI tree base address. */ #define PCI_CONFIG_SPACE (4096U) #define PCI_BUS_MAX (256U) #define PCI_DEV_MAX (32U) -#define PCI_FN_MAX (8U) +#define PCI_FN_MAX (8U) /* version 1.0 */ #define CB_PCI_VERSION (0x0100) #define CB_PCI_DEV_MAGIC (0xfeedd00d) -#define CB_PCI_INT_SZ sizeof(cb_pci_num_t) +#define CB_PCI_INT_SZ sizeof(cb_pci_num_t) #define CB_PCI_NAME_LEN (255U) -typedef char cb_pci_char_t; +typedef char cb_pci_char_t; typedef uintptr_t cb_pci_num_t; typedef uint8_t cb_pci_fn_t; @@ -42,19 +42,18 @@ typedef uint8_t cb_pci_device_t; /// @brief hardware tree header /// used by guest to resolve hardware peripherals. -struct hw_cb_pci_tree -{ - cb_pci_num_t d_magic; - cb_pci_num_t d_version; - cb_pci_num_t d_off_props; - cb_pci_num_t d_off_struct; - cb_pci_num_t d_sz_props; - cb_pci_num_t d_sz_struct; - - cb_pci_num_t d_first_node; - cb_pci_num_t d_next_sibling; - - cb_pci_char_t d_name[CB_PCI_NAME_LEN]; +struct hw_cb_pci_tree { + cb_pci_num_t d_magic; + cb_pci_num_t d_version; + cb_pci_num_t d_off_props; + cb_pci_num_t d_off_struct; + cb_pci_num_t d_sz_props; + cb_pci_num_t d_sz_struct; + + cb_pci_num_t d_first_node; + cb_pci_num_t d_next_sibling; + + cb_pci_char_t d_name[CB_PCI_NAME_LEN]; }; /// @brief Init PCI tree. diff --git a/lib/ppc64/mmu.h b/lib/ppc64/mmu.h index d68fcf5..1953ab5 100644 --- a/lib/ppc64/mmu.h +++ b/lib/ppc64/mmu.h @@ -9,31 +9,30 @@ #include <lib/boot.h> /* Hardware Page Table Entry */ -typedef struct _PTE -{ +typedef struct _PTE { #ifdef CONFIG_PPC64BRIDGE - unsigned long long vsid : 52; - unsigned long api : 5; - unsigned long : 5; - unsigned long h : 1; - unsigned long v : 1; - unsigned long long rpn : 52; -#else /* CONFIG_PPC64BRIDGE */ - unsigned long v : 1; /* Entry is valid */ - unsigned long vsid : 24; /* Virtual segment identifier */ - unsigned long h : 1; /* Hash algorithm indicator */ - unsigned long api : 6; /* Abbreviated page index */ - unsigned long rpn : 20; /* Real (physical) page number */ -#endif /* CONFIG_PPC64BRIDGE */ - unsigned long : 3; /* Unused */ - unsigned long r : 1; /* Referenced */ - unsigned long c : 1; /* Changed */ - unsigned long w : 1; /* Write-thru cache mode */ - unsigned long i : 1; /* Cache inhibited */ - unsigned long m : 1; /* Memory coherence */ - unsigned long g : 1; /* Guarded */ - unsigned long : 1; /* Unused */ - unsigned long pp : 2; /* Page protection */ + unsigned long long vsid : 52; + unsigned long api : 5; + unsigned long : 5; + unsigned long h : 1; + unsigned long v : 1; + unsigned long long rpn : 52; +#else /* CONFIG_PPC64BRIDGE */ + unsigned long v : 1; /* Entry is valid */ + unsigned long vsid : 24; /* Virtual segment identifier */ + unsigned long h : 1; /* Hash algorithm indicator */ + unsigned long api : 6; /* Abbreviated page index */ + unsigned long rpn : 20; /* Real (physical) page number */ +#endif /* CONFIG_PPC64BRIDGE */ + unsigned long : 3; /* Unused */ + unsigned long r : 1; /* Referenced */ + unsigned long c : 1; /* Changed */ + unsigned long w : 1; /* Write-thru cache mode */ + unsigned long i : 1; /* Cache inhibited */ + unsigned long m : 1; /* Memory coherence */ + unsigned long g : 1; /* Guarded */ + unsigned long : 1; /* Unused */ + unsigned long pp : 2; /* Page protection */ } PTE; /* Values for PP (assumes Ks=0, Kp=1) */ @@ -43,76 +42,69 @@ typedef struct _PTE #define PP_RXRX 3 /* Supervisor read, User read */ /* Segment Register */ -typedef struct _SEGREG -{ - unsigned long t : 1; /* Normal or I/O type */ - unsigned long ks : 1; /* Supervisor 'key' (normally 0) */ - unsigned long kp : 1; /* User 'key' (normally 1) */ - unsigned long n : 1; /* No-execute */ - unsigned long : 4; /* Unused */ - unsigned long vsid : 24; /* Virtual Segment Identifier */ +typedef struct _SEGREG { + unsigned long t : 1; /* Normal or I/O type */ + unsigned long ks : 1; /* Supervisor 'key' (normally 0) */ + unsigned long kp : 1; /* User 'key' (normally 1) */ + unsigned long n : 1; /* No-execute */ + unsigned long : 4; /* Unused */ + unsigned long vsid : 24; /* Virtual Segment Identifier */ } SEGREG; /* Block Address Translation (BAT) Registers */ -typedef struct _P601_BATU -{ /* Upper part of BAT for 601 processor */ - unsigned long bepi : 15; /* Effective page index (virtual address) */ - unsigned long : 8; /* unused */ - unsigned long w : 1; - unsigned long i : 1; /* Cache inhibit */ - unsigned long m : 1; /* Memory coherence */ - unsigned long ks : 1; /* Supervisor key (normally 0) */ - unsigned long kp : 1; /* User key (normally 1) */ - unsigned long pp : 2; /* Page access protections */ +typedef struct _P601_BATU { /* Upper part of BAT for 601 processor */ + unsigned long bepi : 15; /* Effective page index (virtual address) */ + unsigned long : 8; /* unused */ + unsigned long w : 1; + unsigned long i : 1; /* Cache inhibit */ + unsigned long m : 1; /* Memory coherence */ + unsigned long ks : 1; /* Supervisor key (normally 0) */ + unsigned long kp : 1; /* User key (normally 1) */ + unsigned long pp : 2; /* Page access protections */ } P601_BATU; -typedef struct _BATU -{ /* Upper part of BAT (all except 601) */ +typedef struct _BATU { /* Upper part of BAT (all except 601) */ #ifdef CONFIG_PPC64BRIDGE - unsigned long long bepi : 47; -#else /* CONFIG_PPC64BRIDGE */ - unsigned long bepi : 15; /* Effective page index (virtual address) */ -#endif /* CONFIG_PPC64BRIDGE */ - unsigned long : 4; /* Unused */ - unsigned long bl : 11; /* Block size mask */ - unsigned long vs : 1; /* Supervisor valid */ - unsigned long vp : 1; /* User valid */ + unsigned long long bepi : 47; +#else /* CONFIG_PPC64BRIDGE */ + unsigned long bepi : 15; /* Effective page index (virtual address) */ +#endif /* CONFIG_PPC64BRIDGE */ + unsigned long : 4; /* Unused */ + unsigned long bl : 11; /* Block size mask */ + unsigned long vs : 1; /* Supervisor valid */ + unsigned long vp : 1; /* User valid */ } BATU; -typedef struct _P601_BATL -{ /* Lower part of BAT for 601 processor */ - unsigned long brpn : 15; /* Real page index (physical address) */ - unsigned long : 10; /* Unused */ - unsigned long v : 1; /* Valid bit */ - unsigned long bl : 6; /* Block size mask */ +typedef struct _P601_BATL { /* Lower part of BAT for 601 processor */ + unsigned long brpn : 15; /* Real page index (physical address) */ + unsigned long : 10; /* Unused */ + unsigned long v : 1; /* Valid bit */ + unsigned long bl : 6; /* Block size mask */ } P601_BATL; -typedef struct _BATL -{ /* Lower part of BAT (all except 601) */ +typedef struct _BATL { /* Lower part of BAT (all except 601) */ #ifdef CONFIG_PPC64BRIDGE - unsigned long long brpn : 47; -#else /* CONFIG_PPC64BRIDGE */ - unsigned long brpn : 15; /* Real page index (physical address) */ -#endif /* CONFIG_PPC64BRIDGE */ - unsigned long : 10; /* Unused */ - unsigned long w : 1; /* Write-thru cache */ - unsigned long i : 1; /* Cache inhibit */ - unsigned long m : 1; /* Memory coherence */ - unsigned long g : 1; /* Guarded (MBZ in IBAT) */ - unsigned long : 1; /* Unused */ - unsigned long pp : 2; /* Page access protections */ + unsigned long long brpn : 47; +#else /* CONFIG_PPC64BRIDGE */ + unsigned long brpn : 15; /* Real page index (physical address) */ +#endif /* CONFIG_PPC64BRIDGE */ + unsigned long : 10; /* Unused */ + unsigned long w : 1; /* Write-thru cache */ + unsigned long i : 1; /* Cache inhibit */ + unsigned long m : 1; /* Memory coherence */ + unsigned long g : 1; /* Guarded (MBZ in IBAT) */ + unsigned long : 1; /* Unused */ + unsigned long pp : 2; /* Page access protections */ } BATL; -typedef struct _BAT -{ - BATU batu; /* Upper register */ - BATL batl; /* Lower register */ +typedef struct _BAT { + BATU batu; /* Upper register */ + BATL batl; /* Lower register */ } BAT; -typedef struct _P601_BAT -{ - P601_BATU batu; /* Upper register */ - P601_BATL batl; /* Lower register */ +typedef struct _P601_BAT { + P601_BATU batu; /* Upper register */ + P601_BATL batl; /* Lower register */ } P601_BAT; /* @@ -124,102 +116,99 @@ typedef struct _P601_BAT * platforms, notably the 80x86 and 680x0. */ -typedef struct _pte -{ - unsigned long page_num : 20; - unsigned long flags : 12; /* Page flags (some unused bits) */ +typedef struct _pte { + unsigned long page_num : 20; + unsigned long flags : 12; /* Page flags (some unused bits) */ } pte; #define PD_SHIFT (10 + 12) /* Page directory */ -#define PD_MASK 0x02FF +#define PD_MASK 0x02FF #define PT_SHIFT (12) /* Page Table */ -#define PT_MASK 0x02FF +#define PT_MASK 0x02FF #define PG_SHIFT (12) /* Page Entry */ /* MMU context */ -typedef struct _MMU_context -{ - SEGREG segs[16]; /* Segment registers */ - pte** pmap; /* Two-level page-map structure */ +typedef struct _MMU_context { + SEGREG segs[16]; /* Segment registers */ + pte** pmap; /* Two-level page-map structure */ } MMU_context; extern void _tlbie(unsigned long va); /* invalidate a TLB entry */ -extern void _tlbia(void); /* invalidate all TLB entries */ +extern void _tlbia(void); /* invalidate all TLB entries */ #ifdef CONFIG_ADDR_MAP extern void init_addr_map(void); #endif -typedef enum -{ - IBAT0 = 0, - IBAT1, - IBAT2, - IBAT3, - DBAT0, - DBAT1, - DBAT2, - DBAT3, +typedef enum { + IBAT0 = 0, + IBAT1, + IBAT2, + IBAT3, + DBAT0, + DBAT1, + DBAT2, + DBAT3, #ifdef CONFIG_HIGH_BATS - IBAT4, - IBAT5, - IBAT6, - IBAT7, - DBAT4, - DBAT5, - DBAT6, - DBAT7 + IBAT4, + IBAT5, + IBAT6, + IBAT7, + DBAT4, + DBAT5, + DBAT6, + DBAT7 #endif } ppc_bat_t; -extern int read_bat(ppc_bat_t bat, unsigned long* upper, unsigned long* lower); -extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower); +extern int read_bat(ppc_bat_t bat, unsigned long* upper, unsigned long* lower); +extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower); extern void print_bats(void); #endif /* __ASSEMBLY__ */ -#define BATU_VS 0x00000002 -#define BATU_VP 0x00000001 +#define BATU_VS 0x00000002 +#define BATU_VP 0x00000001 #define BATU_INVALID 0x00000000 -#define BATL_WRITETHROUGH 0x00000040 -#define BATL_CACHEINHIBIT 0x00000020 -#define BATL_MEMCOHERENCE 0x00000010 +#define BATL_WRITETHROUGH 0x00000040 +#define BATL_CACHEINHIBIT 0x00000020 +#define BATL_MEMCOHERENCE 0x00000010 #define BATL_GUARDEDSTORAGE 0x00000008 -#define BATL_NO_ACCESS 0x00000000 +#define BATL_NO_ACCESS 0x00000000 #define BATL_PP_MSK 0x00000003 -#define BATL_PP_00 0x00000000 /* No access */ -#define BATL_PP_01 0x00000001 /* Read-only */ -#define BATL_PP_10 0x00000002 /* Read-write */ -#define BATL_PP_11 0x00000003 +#define BATL_PP_00 0x00000000 /* No access */ +#define BATL_PP_01 0x00000001 /* Read-only */ +#define BATL_PP_10 0x00000002 /* Read-write */ +#define BATL_PP_11 0x00000003 #define BATL_PP_NO_ACCESS BATL_PP_00 -#define BATL_PP_RO BATL_PP_01 -#define BATL_PP_RW BATL_PP_10 +#define BATL_PP_RO BATL_PP_01 +#define BATL_PP_RW BATL_PP_10 /* BAT Block size values */ #define BATU_BL_128K 0x00000000 #define BATU_BL_256K 0x00000004 #define BATU_BL_512K 0x0000000c -#define BATU_BL_1M 0x0000001c -#define BATU_BL_2M 0x0000003c -#define BATU_BL_4M 0x0000007c -#define BATU_BL_8M 0x000000fc -#define BATU_BL_16M 0x000001fc -#define BATU_BL_32M 0x000003fc -#define BATU_BL_64M 0x000007fc +#define BATU_BL_1M 0x0000001c +#define BATU_BL_2M 0x0000003c +#define BATU_BL_4M 0x0000007c +#define BATU_BL_8M 0x000000fc +#define BATU_BL_16M 0x000001fc +#define BATU_BL_32M 0x000003fc +#define BATU_BL_64M 0x000007fc #define BATU_BL_128M 0x00000ffc #define BATU_BL_256M 0x00001ffc /* Block lengths for processors that support extended block length */ #ifdef HID0_XBSEN #define BATU_BL_512M 0x00003ffc -#define BATU_BL_1G 0x00007ffc -#define BATU_BL_2G 0x0000fffc -#define BATU_BL_4G 0x0001fffc -#define BATU_BL_MAX BATU_BL_4G +#define BATU_BL_1G 0x00007ffc +#define BATU_BL_2G 0x0000fffc +#define BATU_BL_4G 0x0001fffc +#define BATU_BL_MAX BATU_BL_4G #else #define BATU_BL_MAX BATU_BL_256M #endif @@ -232,28 +221,28 @@ extern void print_bats(void); /* Macros to get values from BATs, once data is in the BAT register format */ #define BATU_VALID(x) (x & 0x3) #define BATU_VADDR(x) (x & 0xfffe0000) -#define BATL_PADDR(x) ((phys_addr_t)((x & 0xfffe0000) | ((x & 0x0e00ULL) << 24) | ((x & 0x04ULL) << 30))) -#define BATU_SIZE(x) (1ULL << (fls((x & BATU_BL_MAX) >> 2) + 17)) +#define BATL_PADDR(x) \ + ((phys_addr_t) ((x & 0xfffe0000) | ((x & 0x0e00ULL) << 24) | ((x & 0x04ULL) << 30))) +#define BATU_SIZE(x) (1ULL << (fls((x & BATU_BL_MAX) >> 2) + 17)) /* bytes into BATU_BL */ -#define TO_BATU_BL(x) \ - (uint32_t)((((1ull << __ilog2_u64((uint64_t)x)) / (128 * 1024)) - 1) * 4) +#define TO_BATU_BL(x) (uint32_t)((((1ull << __ilog2_u64((uint64_t) x)) / (128 * 1024)) - 1) * 4) /* Used to set up SDR1 register */ -#define HASH_TABLE_SIZE_64K 0x00010000 +#define HASH_TABLE_SIZE_64K 0x00010000 #define HASH_TABLE_SIZE_128K 0x00020000 #define HASH_TABLE_SIZE_256K 0x00040000 #define HASH_TABLE_SIZE_512K 0x00080000 -#define HASH_TABLE_SIZE_1M 0x00100000 -#define HASH_TABLE_SIZE_2M 0x00200000 -#define HASH_TABLE_SIZE_4M 0x00400000 -#define HASH_TABLE_MASK_64K 0x000 +#define HASH_TABLE_SIZE_1M 0x00100000 +#define HASH_TABLE_SIZE_2M 0x00200000 +#define HASH_TABLE_SIZE_4M 0x00400000 +#define HASH_TABLE_MASK_64K 0x000 #define HASH_TABLE_MASK_128K 0x001 #define HASH_TABLE_MASK_256K 0x003 #define HASH_TABLE_MASK_512K 0x007 -#define HASH_TABLE_MASK_1M 0x00F -#define HASH_TABLE_MASK_2M 0x01F -#define HASH_TABLE_MASK_4M 0x03F +#define HASH_TABLE_MASK_1M 0x00F +#define HASH_TABLE_MASK_2M 0x01F +#define HASH_TABLE_MASK_4M 0x03F /* Control/status registers for the MPC8xx. * A write operation to these registers causes serialized access. @@ -262,13 +251,13 @@ extern void print_bats(void); * is written, and the contents of several registers are used to * create the entry. */ -#define MI_CTR 784 /* Instruction TLB control register */ -#define MI_GPM 0x80000000 /* Set domain manager mode */ -#define MI_PPM 0x40000000 /* Set subpage protection */ -#define MI_CIDEF 0x20000000 /* Set cache inhibit when MMU dis */ -#define MI_RSV4I 0x08000000 /* Reserve 4 TLB entries */ -#define MI_PPCS 0x02000000 /* Use MI_RPN prob/priv state */ -#define MI_IDXMASK 0x00001f00 /* TLB index to be loaded */ +#define MI_CTR 784 /* Instruction TLB control register */ +#define MI_GPM 0x80000000 /* Set domain manager mode */ +#define MI_PPM 0x40000000 /* Set subpage protection */ +#define MI_CIDEF 0x20000000 /* Set cache inhibit when MMU dis */ +#define MI_RSV4I 0x08000000 /* Reserve 4 TLB entries */ +#define MI_PPCS 0x02000000 /* Use MI_RPN prob/priv state */ +#define MI_IDXMASK 0x00001f00 /* TLB index to be loaded */ #define MI_RESETVAL 0x00000000 /* Value of register at reset */ /* These are the Ks and Kp from the PowerPC books. For proper operation, @@ -282,25 +271,25 @@ extern void print_bats(void); * about the last instruction TLB miss. When MI_RPN is written, bits in * this register are used to create the TLB entry. */ -#define MI_EPN 787 -#define MI_EPNMASK 0xfffff000 /* Effective page number for entry */ -#define MI_EVALID 0x00000200 /* Entry is valid */ +#define MI_EPN 787 +#define MI_EPNMASK 0xfffff000 /* Effective page number for entry */ +#define MI_EVALID 0x00000200 /* Entry is valid */ #define MI_ASIDMASK 0x0000000f /* ASID match value */ - /* Reset value is undefined */ + /* Reset value is undefined */ /* A "level 1" or "segment" or whatever you want to call it register. * For the instruction TLB, it contains bits that get loaded into the * TLB entry when the MI_RPN is written. */ -#define MI_TWC 789 -#define MI_APG 0x000001e0 /* Access protection group (0) */ -#define MI_GUARDED 0x00000010 /* Guarded storage */ -#define MI_PSMASK 0x0000000c /* Mask of page size bits */ -#define MI_PS8MEG 0x0000000c /* 8M page size */ -#define MI_PS512K 0x00000004 /* 512K page size */ +#define MI_TWC 789 +#define MI_APG 0x000001e0 /* Access protection group (0) */ +#define MI_GUARDED 0x00000010 /* Guarded storage */ +#define MI_PSMASK 0x0000000c /* Mask of page size bits */ +#define MI_PS8MEG 0x0000000c /* 8M page size */ +#define MI_PS512K 0x00000004 /* 512K page size */ #define MI_PS4K_16K 0x00000000 /* 4K or 16K page size */ -#define MI_SVALID 0x00000001 /* Segment entry is valid */ - /* Reset value is undefined */ +#define MI_SVALID 0x00000001 /* Segment entry is valid */ + /* Reset value is undefined */ /* Real page number. Defined by the pte. Writing this register * causes a TLB entry to be created for the instruction TLB, using @@ -315,18 +304,18 @@ extern void print_bats(void); */ #define MI_BOOTINIT 0x000001fd -#define MD_CTR 792 /* Data TLB control register */ -#define MD_GPM 0x80000000 /* Set domain manager mode */ -#define MD_PPM 0x40000000 /* Set subpage protection */ -#define MD_CIDEF 0x20000000 /* Set cache inhibit when MMU dis */ -#define MD_WTDEF 0x10000000 /* Set writethrough when MMU dis */ -#define MD_RSV4I 0x08000000 /* Reserve 4 TLB entries */ -#define MD_TWAM 0x04000000 /* Use 4K page hardware assist */ -#define MD_PPCS 0x02000000 /* Use MI_RPN prob/priv state */ -#define MD_IDXMASK 0x00001f00 /* TLB index to be loaded */ +#define MD_CTR 792 /* Data TLB control register */ +#define MD_GPM 0x80000000 /* Set domain manager mode */ +#define MD_PPM 0x40000000 /* Set subpage protection */ +#define MD_CIDEF 0x20000000 /* Set cache inhibit when MMU dis */ +#define MD_WTDEF 0x10000000 /* Set writethrough when MMU dis */ +#define MD_RSV4I 0x08000000 /* Reserve 4 TLB entries */ +#define MD_TWAM 0x04000000 /* Use 4K page hardware assist */ +#define MD_PPCS 0x02000000 /* Use MI_RPN prob/priv state */ +#define MD_IDXMASK 0x00001f00 /* TLB index to be loaded */ #define MD_RESETVAL 0x04000000 /* Value of register at reset */ -#define M_CASID 793 /* Address space ID (context) to match */ +#define M_CASID 793 /* Address space ID (context) to match */ #define MC_ASIDMASK 0x0000000f /* Bits used for ASID value */ /* These are the Ks and Kp from the PowerPC books. For proper operation, @@ -340,38 +329,38 @@ extern void print_bats(void); * about the last instruction TLB miss. When MD_RPN is written, bits in * this register are used to create the TLB entry. */ -#define MD_EPN 795 -#define MD_EPNMASK 0xfffff000 /* Effective page number for entry */ -#define MD_EVALID 0x00000200 /* Entry is valid */ +#define MD_EPN 795 +#define MD_EPNMASK 0xfffff000 /* Effective page number for entry */ +#define MD_EVALID 0x00000200 /* Entry is valid */ #define MD_ASIDMASK 0x0000000f /* ASID match value */ - /* Reset value is undefined */ + /* Reset value is undefined */ /* The pointer to the base address of the first level page table. * During a software tablewalk, reading this register provides the address * of the entry associated with MD_EPN. */ -#define M_TWB 796 -#define M_L1TB 0xfffff000 /* Level 1 table base address */ +#define M_TWB 796 +#define M_L1TB 0xfffff000 /* Level 1 table base address */ #define M_L1INDX 0x00000ffc /* Level 1 index, when read */ - /* Reset value is undefined */ + /* Reset value is undefined */ /* A "level 1" or "segment" or whatever you want to call it register. * For the data TLB, it contains bits that get loaded into the TLB entry * when the MD_RPN is written. It is also provides the hardware assist * for finding the PTE address during software tablewalk. */ -#define MD_TWC 797 -#define MD_L2TB 0xfffff000 /* Level 2 table base address */ -#define MD_L2INDX 0xfffffe00 /* Level 2 index (*pte), when read */ -#define MD_APG 0x000001e0 /* Access protection group (0) */ -#define MD_GUARDED 0x00000010 /* Guarded storage */ -#define MD_PSMASK 0x0000000c /* Mask of page size bits */ -#define MD_PS8MEG 0x0000000c /* 8M page size */ -#define MD_PS512K 0x00000004 /* 512K page size */ +#define MD_TWC 797 +#define MD_L2TB 0xfffff000 /* Level 2 table base address */ +#define MD_L2INDX 0xfffffe00 /* Level 2 index (*pte), when read */ +#define MD_APG 0x000001e0 /* Access protection group (0) */ +#define MD_GUARDED 0x00000010 /* Guarded storage */ +#define MD_PSMASK 0x0000000c /* Mask of page size bits */ +#define MD_PS8MEG 0x0000000c /* 8M page size */ +#define MD_PS512K 0x00000004 /* 512K page size */ #define MD_PS4K_16K 0x00000000 /* 4K or 16K page size */ -#define MD_WT 0x00000002 /* Use writethrough page attribute */ -#define MD_SVALID 0x00000001 /* Segment entry is valid */ - /* Reset value is undefined */ +#define MD_WT 0x00000002 /* Use writethrough page attribute */ +#define MD_SVALID 0x00000001 /* Segment entry is valid */ + /* Reset value is undefined */ /* Real page number. Defined by the pte. Writing this register * causes a TLB entry to be created for the data TLB, using @@ -410,200 +399,192 @@ extern void print_bats(void); */ #define MAS0_TLBSEL_MSK 0x30000000 -#define MAS0_TLBSEL(x) (((x) << 28) & MAS0_TLBSEL_MSK) -#define MAS0_ESEL_MSK 0x0FFF0000 -#define MAS0_ESEL(x) (((x) << 16) & MAS0_ESEL_MSK) -#define MAS0_NV(x) ((x)&0x00000FFF) - -#define MAS1_VALID 0x80000000 -#define MAS1_IPROT 0x40000000 -#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000) -#define MAS1_TS 0x00001000 -#define MAS1_TSIZE(x) (((x) << 7) & 0x00000F80) +#define MAS0_TLBSEL(x) (((x) << 28) & MAS0_TLBSEL_MSK) +#define MAS0_ESEL_MSK 0x0FFF0000 +#define MAS0_ESEL(x) (((x) << 16) & MAS0_ESEL_MSK) +#define MAS0_NV(x) ((x) & 0x00000FFF) + +#define MAS1_VALID 0x80000000 +#define MAS1_IPROT 0x40000000 +#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000) +#define MAS1_TS 0x00001000 +#define MAS1_TSIZE(x) (((x) << 7) & 0x00000F80) #define TSIZE_TO_BYTES(x) (1ULL << ((x) + 10)) #define MAS2_EPN 0xFFFFF000 -#define MAS2_X0 0x00000040 -#define MAS2_X1 0x00000020 -#define MAS2_W 0x00000010 -#define MAS2_I 0x00000008 -#define MAS2_M 0x00000004 -#define MAS2_G 0x00000002 -#define MAS2_E 0x00000001 +#define MAS2_X0 0x00000040 +#define MAS2_X1 0x00000020 +#define MAS2_W 0x00000010 +#define MAS2_I 0x00000008 +#define MAS2_M 0x00000004 +#define MAS2_G 0x00000002 +#define MAS2_E 0x00000001 #define MAS3_RPN 0xFFFFF000 -#define MAS3_U0 0x00000200 -#define MAS3_U1 0x00000100 -#define MAS3_U2 0x00000080 -#define MAS3_U3 0x00000040 -#define MAS3_UX 0x00000020 -#define MAS3_SX 0x00000010 -#define MAS3_UW 0x00000008 -#define MAS3_SW 0x00000004 -#define MAS3_UR 0x00000002 -#define MAS3_SR 0x00000001 +#define MAS3_U0 0x00000200 +#define MAS3_U1 0x00000100 +#define MAS3_U2 0x00000080 +#define MAS3_U3 0x00000040 +#define MAS3_UX 0x00000020 +#define MAS3_SX 0x00000010 +#define MAS3_UW 0x00000008 +#define MAS3_SW 0x00000004 +#define MAS3_UR 0x00000002 +#define MAS3_SR 0x00000001 #define MAS4_TLBSELD(x) MAS0_TLBSEL(x) -#define MAS4_TIDDSEL 0x000F0000 -#define MAS4_TSIZED(x) MAS1_TSIZE(x) -#define MAS4_X0D 0x00000040 -#define MAS4_X1D 0x00000020 -#define MAS4_WD 0x00000010 -#define MAS4_ID 0x00000008 -#define MAS4_MD 0x00000004 -#define MAS4_GD 0x00000002 -#define MAS4_ED 0x00000001 +#define MAS4_TIDDSEL 0x000F0000 +#define MAS4_TSIZED(x) MAS1_TSIZE(x) +#define MAS4_X0D 0x00000040 +#define MAS4_X1D 0x00000020 +#define MAS4_WD 0x00000010 +#define MAS4_ID 0x00000008 +#define MAS4_MD 0x00000004 +#define MAS4_GD 0x00000002 +#define MAS4_ED 0x00000001 #define MAS6_SPID0 0x3FFF0000 #define MAS6_SPID1 0x00007FFE -#define MAS6_SAS 0x00000001 -#define MAS6_SPID MAS6_SPID0 +#define MAS6_SAS 0x00000001 +#define MAS6_SPID MAS6_SPID0 #define MAS7_RPN 0xFFFFFFFF -#define FSL_BOOKE_MAS0(tlbsel, esel, nv) \ - (MAS0_TLBSEL(tlbsel) | MAS0_ESEL(esel) | MAS0_NV(nv)) -#define FSL_BOOKE_MAS1(v, iprot, tid, ts, tsize) \ - ((((v) << 31) & MAS1_VALID) | \ - (((iprot) << 30) & MAS1_IPROT) | \ - (MAS1_TID(tid)) | \ - (((ts) << 12) & MAS1_TS) | \ - (MAS1_TSIZE(tsize))) -#define FSL_BOOKE_MAS2(epn, wimge) \ - (((epn)&MAS3_RPN) | (wimge)) -#define FSL_BOOKE_MAS3(rpn, user, perms) \ - (((rpn)&MAS3_RPN) | (user) | (perms)) -#define FSL_BOOKE_MAS7(rpn) \ - (((uint64_t)(rpn)) >> 32) - -#define BOOKE_PAGESZ_1K 0 -#define BOOKE_PAGESZ_2K 1 -#define BOOKE_PAGESZ_4K 2 -#define BOOKE_PAGESZ_8K 3 -#define BOOKE_PAGESZ_16K 4 -#define BOOKE_PAGESZ_32K 5 -#define BOOKE_PAGESZ_64K 6 -#define BOOKE_PAGESZ_128K 7 -#define BOOKE_PAGESZ_256K 8 -#define BOOKE_PAGESZ_512K 9 -#define BOOKE_PAGESZ_1M 10 -#define BOOKE_PAGESZ_2M 11 -#define BOOKE_PAGESZ_4M 12 -#define BOOKE_PAGESZ_8M 13 -#define BOOKE_PAGESZ_16M 14 -#define BOOKE_PAGESZ_32M 15 -#define BOOKE_PAGESZ_64M 16 -#define BOOKE_PAGESZ_128M 17 -#define BOOKE_PAGESZ_256M 18 -#define BOOKE_PAGESZ_512M 19 -#define BOOKE_PAGESZ_1G 20 -#define BOOKE_PAGESZ_2G 21 -#define BOOKE_PAGESZ_4G 22 -#define BOOKE_PAGESZ_8G 23 -#define BOOKE_PAGESZ_16GB 24 -#define BOOKE_PAGESZ_32GB 25 -#define BOOKE_PAGESZ_64GB 26 +#define FSL_BOOKE_MAS0(tlbsel, esel, nv) (MAS0_TLBSEL(tlbsel) | MAS0_ESEL(esel) | MAS0_NV(nv)) +#define FSL_BOOKE_MAS1(v, iprot, tid, ts, tsize) \ + ((((v) << 31) & MAS1_VALID) | (((iprot) << 30) & MAS1_IPROT) | (MAS1_TID(tid)) | \ + (((ts) << 12) & MAS1_TS) | (MAS1_TSIZE(tsize))) +#define FSL_BOOKE_MAS2(epn, wimge) (((epn) & MAS3_RPN) | (wimge)) +#define FSL_BOOKE_MAS3(rpn, user, perms) (((rpn) & MAS3_RPN) | (user) | (perms)) +#define FSL_BOOKE_MAS7(rpn) (((uint64_t) (rpn)) >> 32) + +#define BOOKE_PAGESZ_1K 0 +#define BOOKE_PAGESZ_2K 1 +#define BOOKE_PAGESZ_4K 2 +#define BOOKE_PAGESZ_8K 3 +#define BOOKE_PAGESZ_16K 4 +#define BOOKE_PAGESZ_32K 5 +#define BOOKE_PAGESZ_64K 6 +#define BOOKE_PAGESZ_128K 7 +#define BOOKE_PAGESZ_256K 8 +#define BOOKE_PAGESZ_512K 9 +#define BOOKE_PAGESZ_1M 10 +#define BOOKE_PAGESZ_2M 11 +#define BOOKE_PAGESZ_4M 12 +#define BOOKE_PAGESZ_8M 13 +#define BOOKE_PAGESZ_16M 14 +#define BOOKE_PAGESZ_32M 15 +#define BOOKE_PAGESZ_64M 16 +#define BOOKE_PAGESZ_128M 17 +#define BOOKE_PAGESZ_256M 18 +#define BOOKE_PAGESZ_512M 19 +#define BOOKE_PAGESZ_1G 20 +#define BOOKE_PAGESZ_2G 21 +#define BOOKE_PAGESZ_4G 22 +#define BOOKE_PAGESZ_8G 23 +#define BOOKE_PAGESZ_16GB 24 +#define BOOKE_PAGESZ_32GB 25 +#define BOOKE_PAGESZ_64GB 26 #define BOOKE_PAGESZ_128GB 27 #define BOOKE_PAGESZ_256GB 28 #define BOOKE_PAGESZ_512GB 29 -#define BOOKE_PAGESZ_1TB 30 -#define BOOKE_PAGESZ_2TB 31 +#define BOOKE_PAGESZ_1TB 30 +#define BOOKE_PAGESZ_2TB 31 -#define TLBIVAX_ALL 4 +#define TLBIVAX_ALL 4 #define TLBIVAX_TLB0 0 #define TLBIVAX_TLB1 8 #ifdef CONFIG_E500 #ifndef __ASSEMBLY__ -extern void set_tlb(uint8_t tlb, uint32_t epn, uint64_t rpn, uint8_t perms, uint8_t wimge, uint8_t ts, uint8_t esel, uint8_t tsize, uint8_t iprot); +extern void set_tlb(uint8_t tlb, uint32_t epn, uint64_t rpn, uint8_t perms, uint8_t wimge, + uint8_t ts, uint8_t esel, uint8_t tsize, uint8_t iprot); extern void disable_tlb(uint8_t esel); extern void invalidate_tlb(uint8_t tlb); extern void init_tlbs(void); -extern int find_tlb_idx(void* addr, uint8_t tlbsel); +extern int find_tlb_idx(void* addr, uint8_t tlbsel); extern void init_used_tlb_cams(void); -extern int find_free_tlbcam(void); +extern int find_free_tlbcam(void); extern void print_tlbcam(void); extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg); -extern void clear_ddr_tlbs(unsigned int memsize_in_meg); +extern void clear_ddr_tlbs(unsigned int memsize_in_meg); -enum tlb_map_type -{ - TLB_MAP_RAM, - TLB_MAP_IO, +enum tlb_map_type { + TLB_MAP_RAM, + TLB_MAP_IO, }; -extern uint64_t tlb_map_range(ulong_t v_addr, phys_addr_t p_addr, uint64_t size, enum tlb_map_type map_type); - -extern void write_tlb(uint32_t _mas0, uint32_t _mas1, uint32_t _mas2, uint32_t _mas3, uint32_t _mas7); - -#define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \ - { \ - .mas0 = FSL_BOOKE_MAS0(_tlb, _esel, 0), \ - .mas1 = FSL_BOOKE_MAS1(1, _iprot, 0, _ts, _sz), \ - .mas2 = FSL_BOOKE_MAS2(_epn, _wimge), \ - .mas3 = FSL_BOOKE_MAS3(_rpn, 0, _perms), \ - .mas7 = FSL_BOOKE_MAS7(_rpn), \ - } - -struct fsl_e_tlb_entry -{ - uint32_t mas0; - uint32_t mas1; - uint32_t mas2; - uint32_t mas3; - uint32_t mas7; +extern uint64_t tlb_map_range(ulong_t v_addr, phys_addr_t p_addr, uint64_t size, + enum tlb_map_type map_type); + +extern void write_tlb(uint32_t _mas0, uint32_t _mas1, uint32_t _mas2, uint32_t _mas3, + uint32_t _mas7); + +#define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \ + { \ + .mas0 = FSL_BOOKE_MAS0(_tlb, _esel, 0), .mas1 = FSL_BOOKE_MAS1(1, _iprot, 0, _ts, _sz), \ + .mas2 = FSL_BOOKE_MAS2(_epn, _wimge), .mas3 = FSL_BOOKE_MAS3(_rpn, 0, _perms), \ + .mas7 = FSL_BOOKE_MAS7(_rpn), \ + } + +struct fsl_e_tlb_entry { + uint32_t mas0; + uint32_t mas1; + uint32_t mas2; + uint32_t mas3; + uint32_t mas7; }; extern struct fsl_e_tlb_entry tlb_table[]; -extern int num_tlb_entries; +extern int num_tlb_entries; #endif #endif #ifdef CONFIG_E300 -#define LAWAR_EN 0x80000000 +#define LAWAR_EN 0x80000000 #define LAWAR_SIZE 0x0000003F -#define LAWAR_TRGT_IF_PCI 0x00000000 -#define LAWAR_TRGT_IF_PCI1 0x00000000 -#define LAWAR_TRGT_IF_PCIX 0x00000000 -#define LAWAR_TRGT_IF_PCI2 0x00100000 -#define LAWAR_TRGT_IF_PCIE1 0x00200000 -#define LAWAR_TRGT_IF_PCIE2 0x00100000 -#define LAWAR_TRGT_IF_PCIE3 0x00300000 -#define LAWAR_TRGT_IF_LBC 0x00400000 -#define LAWAR_TRGT_IF_CCSR 0x00800000 +#define LAWAR_TRGT_IF_PCI 0x00000000 +#define LAWAR_TRGT_IF_PCI1 0x00000000 +#define LAWAR_TRGT_IF_PCIX 0x00000000 +#define LAWAR_TRGT_IF_PCI2 0x00100000 +#define LAWAR_TRGT_IF_PCIE1 0x00200000 +#define LAWAR_TRGT_IF_PCIE2 0x00100000 +#define LAWAR_TRGT_IF_PCIE3 0x00300000 +#define LAWAR_TRGT_IF_LBC 0x00400000 +#define LAWAR_TRGT_IF_CCSR 0x00800000 #define LAWAR_TRGT_IF_DDR_INTERLEAVED 0x00B00000 -#define LAWAR_TRGT_IF_RIO 0x00c00000 -#define LAWAR_TRGT_IF_DDR 0x00f00000 -#define LAWAR_TRGT_IF_DDR1 0x00f00000 -#define LAWAR_TRGT_IF_DDR2 0x01600000 +#define LAWAR_TRGT_IF_RIO 0x00c00000 +#define LAWAR_TRGT_IF_DDR 0x00f00000 +#define LAWAR_TRGT_IF_DDR1 0x00f00000 +#define LAWAR_TRGT_IF_DDR2 0x01600000 #define LAWAR_SIZE_BASE 0xa -#define LAWAR_SIZE_4K (LAWAR_SIZE_BASE + 1) -#define LAWAR_SIZE_8K (LAWAR_SIZE_BASE + 2) -#define LAWAR_SIZE_16K (LAWAR_SIZE_BASE + 3) -#define LAWAR_SIZE_32K (LAWAR_SIZE_BASE + 4) -#define LAWAR_SIZE_64K (LAWAR_SIZE_BASE + 5) +#define LAWAR_SIZE_4K (LAWAR_SIZE_BASE + 1) +#define LAWAR_SIZE_8K (LAWAR_SIZE_BASE + 2) +#define LAWAR_SIZE_16K (LAWAR_SIZE_BASE + 3) +#define LAWAR_SIZE_32K (LAWAR_SIZE_BASE + 4) +#define LAWAR_SIZE_64K (LAWAR_SIZE_BASE + 5) #define LAWAR_SIZE_128K (LAWAR_SIZE_BASE + 6) #define LAWAR_SIZE_256K (LAWAR_SIZE_BASE + 7) #define LAWAR_SIZE_512K (LAWAR_SIZE_BASE + 8) -#define LAWAR_SIZE_1M (LAWAR_SIZE_BASE + 9) -#define LAWAR_SIZE_2M (LAWAR_SIZE_BASE + 10) -#define LAWAR_SIZE_4M (LAWAR_SIZE_BASE + 11) -#define LAWAR_SIZE_8M (LAWAR_SIZE_BASE + 12) -#define LAWAR_SIZE_16M (LAWAR_SIZE_BASE + 13) -#define LAWAR_SIZE_32M (LAWAR_SIZE_BASE + 14) -#define LAWAR_SIZE_64M (LAWAR_SIZE_BASE + 15) +#define LAWAR_SIZE_1M (LAWAR_SIZE_BASE + 9) +#define LAWAR_SIZE_2M (LAWAR_SIZE_BASE + 10) +#define LAWAR_SIZE_4M (LAWAR_SIZE_BASE + 11) +#define LAWAR_SIZE_8M (LAWAR_SIZE_BASE + 12) +#define LAWAR_SIZE_16M (LAWAR_SIZE_BASE + 13) +#define LAWAR_SIZE_32M (LAWAR_SIZE_BASE + 14) +#define LAWAR_SIZE_64M (LAWAR_SIZE_BASE + 15) #define LAWAR_SIZE_128M (LAWAR_SIZE_BASE + 16) #define LAWAR_SIZE_256M (LAWAR_SIZE_BASE + 17) #define LAWAR_SIZE_512M (LAWAR_SIZE_BASE + 18) -#define LAWAR_SIZE_1G (LAWAR_SIZE_BASE + 19) -#define LAWAR_SIZE_2G (LAWAR_SIZE_BASE + 20) -#define LAWAR_SIZE_4G (LAWAR_SIZE_BASE + 21) -#define LAWAR_SIZE_8G (LAWAR_SIZE_BASE + 22) -#define LAWAR_SIZE_16G (LAWAR_SIZE_BASE + 23) -#define LAWAR_SIZE_32G (LAWAR_SIZE_BASE + 24) +#define LAWAR_SIZE_1G (LAWAR_SIZE_BASE + 19) +#define LAWAR_SIZE_2G (LAWAR_SIZE_BASE + 20) +#define LAWAR_SIZE_4G (LAWAR_SIZE_BASE + 21) +#define LAWAR_SIZE_8G (LAWAR_SIZE_BASE + 22) +#define LAWAR_SIZE_16G (LAWAR_SIZE_BASE + 23) +#define LAWAR_SIZE_32G (LAWAR_SIZE_BASE + 24) #endif #ifdef CONFIG_440 @@ -612,13 +593,13 @@ extern int num_tlb_entries; /* Supported page sizes */ -#define SZ_1K 0x00000000 -#define SZ_4K 0x00000010 -#define SZ_16K 0x00000020 -#define SZ_64K 0x00000030 +#define SZ_1K 0x00000000 +#define SZ_4K 0x00000010 +#define SZ_16K 0x00000020 +#define SZ_64K 0x00000030 #define SZ_256K 0x00000040 -#define SZ_1M 0x00000050 -#define SZ_16M 0x00000070 +#define SZ_1M 0x00000050 +#define SZ_16M 0x00000070 #define SZ_256M 0x00000090 /* Storage attributes */ @@ -635,151 +616,147 @@ extern int num_tlb_entries; #define AC_W 0x00000012 /* Write */ #define AC_R 0x00000009 /* Read */ /* Some additional macros for combinations often used */ -#define AC_RW (AC_R | AC_W) +#define AC_RW (AC_R | AC_W) #define AC_RWX (AC_R | AC_W | AC_X) /* Some handy macros */ -#define EPN(e) ((e)&0xfffffc00) -#define TLB0(epn, sz) ((EPN((epn)) | (sz) | TLB_VALID)) -#define TLB1(rpn, erpn) (((rpn)&0xfffffc00) | (erpn)) -#define TLB2(a) ((a)&0x00000fbf) +#define EPN(e) ((e) & 0xfffffc00) +#define TLB0(epn, sz) ((EPN((epn)) | (sz) | TLB_VALID)) +#define TLB1(rpn, erpn) (((rpn) & 0xfffffc00) | (erpn)) +#define TLB2(a) ((a) & 0x00000fbf) #define tlbtab_start \ - mflr r1; \ - bl 0f; + mflr r1; \ + bl 0f; #define tlbtab_end \ - .long 0, 0, 0; \ - 0 : mflr r0; \ - mtlr r1; \ - blr; + .long 0, 0, 0; \ + 0 : mflr r0; \ + mtlr r1; \ + blr; -#define tlbentry(epn, sz, rpn, erpn, attr) \ - .long TLB0(epn, sz), TLB1(rpn, erpn), TLB2(attr) +#define tlbentry(epn, sz, rpn, erpn, attr) .long TLB0(epn, sz), TLB1(rpn, erpn), TLB2(attr) /*----------------------------------------------------------------------------+ | TLB specific defines. +----------------------------------------------------------------------------*/ #define TLB_256MB_ALIGN_MASK 0xFF0000000ULL -#define TLB_16MB_ALIGN_MASK 0xFFF000000ULL -#define TLB_1MB_ALIGN_MASK 0xFFFF00000ULL +#define TLB_16MB_ALIGN_MASK 0xFFF000000ULL +#define TLB_1MB_ALIGN_MASK 0xFFFF00000ULL #define TLB_256KB_ALIGN_MASK 0xFFFFC0000ULL -#define TLB_64KB_ALIGN_MASK 0xFFFFF0000ULL -#define TLB_16KB_ALIGN_MASK 0xFFFFFC000ULL -#define TLB_4KB_ALIGN_MASK 0xFFFFFF000ULL -#define TLB_1KB_ALIGN_MASK 0xFFFFFFC00ULL -#define TLB_256MB_SIZE 0x10000000 -#define TLB_16MB_SIZE 0x01000000 -#define TLB_1MB_SIZE 0x00100000 -#define TLB_256KB_SIZE 0x00040000 -#define TLB_64KB_SIZE 0x00010000 -#define TLB_16KB_SIZE 0x00004000 -#define TLB_4KB_SIZE 0x00001000 -#define TLB_1KB_SIZE 0x00000400 - -#define TLB_WORD0_EPN_MASK 0xFFFFFC00 -#define TLB_WORD0_EPN_ENCODE(n) (((unsigned long)(n)) & 0xFFFFFC00) -#define TLB_WORD0_EPN_DECODE(n) (((unsigned long)(n)) & 0xFFFFFC00) -#define TLB_WORD0_V_MASK 0x00000200 -#define TLB_WORD0_V_ENABLE 0x00000200 -#define TLB_WORD0_V_DISABLE 0x00000000 -#define TLB_WORD0_TS_MASK 0x00000100 -#define TLB_WORD0_TS_1 0x00000100 -#define TLB_WORD0_TS_0 0x00000000 -#define TLB_WORD0_SIZE_MASK 0x000000F0 -#define TLB_WORD0_SIZE_1KB 0x00000000 -#define TLB_WORD0_SIZE_4KB 0x00000010 -#define TLB_WORD0_SIZE_16KB 0x00000020 -#define TLB_WORD0_SIZE_64KB 0x00000030 -#define TLB_WORD0_SIZE_256KB 0x00000040 -#define TLB_WORD0_SIZE_1MB 0x00000050 -#define TLB_WORD0_SIZE_16MB 0x00000070 -#define TLB_WORD0_SIZE_256MB 0x00000090 -#define TLB_WORD0_TPAR_MASK 0x0000000F -#define TLB_WORD0_TPAR_ENCODE(n) ((((unsigned long)(n)) & 0x0F) << 0) -#define TLB_WORD0_TPAR_DECODE(n) ((((unsigned long)(n)) >> 0) & 0x0F) - -#define TLB_WORD1_RPN_MASK 0xFFFFFC00 -#define TLB_WORD1_RPN_ENCODE(n) (((unsigned long)(n)) & 0xFFFFFC00) -#define TLB_WORD1_RPN_DECODE(n) (((unsigned long)(n)) & 0xFFFFFC00) -#define TLB_WORD1_PAR1_MASK 0x00000300 -#define TLB_WORD1_PAR1_ENCODE(n) ((((unsigned long)(n)) & 0x03) << 8) -#define TLB_WORD1_PAR1_DECODE(n) ((((unsigned long)(n)) >> 8) & 0x03) -#define TLB_WORD1_PAR1_0 0x00000000 -#define TLB_WORD1_PAR1_1 0x00000100 -#define TLB_WORD1_PAR1_2 0x00000200 -#define TLB_WORD1_PAR1_3 0x00000300 -#define TLB_WORD1_ERPN_MASK 0x0000000F -#define TLB_WORD1_ERPN_ENCODE(n) ((((unsigned long)(n)) & 0x0F) << 0) -#define TLB_WORD1_ERPN_DECODE(n) ((((unsigned long)(n)) >> 0) & 0x0F) - -#define TLB_WORD2_PAR2_MASK 0xC0000000 -#define TLB_WORD2_PAR2_ENCODE(n) ((((unsigned long)(n)) & 0x03) << 30) -#define TLB_WORD2_PAR2_DECODE(n) ((((unsigned long)(n)) >> 30) & 0x03) -#define TLB_WORD2_PAR2_0 0x00000000 -#define TLB_WORD2_PAR2_1 0x40000000 -#define TLB_WORD2_PAR2_2 0x80000000 -#define TLB_WORD2_PAR2_3 0xC0000000 -#define TLB_WORD2_U0_MASK 0x00008000 -#define TLB_WORD2_U0_ENABLE 0x00008000 -#define TLB_WORD2_U0_DISABLE 0x00000000 -#define TLB_WORD2_U1_MASK 0x00004000 -#define TLB_WORD2_U1_ENABLE 0x00004000 -#define TLB_WORD2_U1_DISABLE 0x00000000 -#define TLB_WORD2_U2_MASK 0x00002000 -#define TLB_WORD2_U2_ENABLE 0x00002000 -#define TLB_WORD2_U2_DISABLE 0x00000000 -#define TLB_WORD2_U3_MASK 0x00001000 -#define TLB_WORD2_U3_ENABLE 0x00001000 -#define TLB_WORD2_U3_DISABLE 0x00000000 -#define TLB_WORD2_W_MASK 0x00000800 -#define TLB_WORD2_W_ENABLE 0x00000800 -#define TLB_WORD2_W_DISABLE 0x00000000 -#define TLB_WORD2_I_MASK 0x00000400 -#define TLB_WORD2_I_ENABLE 0x00000400 -#define TLB_WORD2_I_DISABLE 0x00000000 -#define TLB_WORD2_M_MASK 0x00000200 -#define TLB_WORD2_M_ENABLE 0x00000200 -#define TLB_WORD2_M_DISABLE 0x00000000 -#define TLB_WORD2_G_MASK 0x00000100 -#define TLB_WORD2_G_ENABLE 0x00000100 -#define TLB_WORD2_G_DISABLE 0x00000000 -#define TLB_WORD2_E_MASK 0x00000080 -#define TLB_WORD2_E_ENABLE 0x00000080 -#define TLB_WORD2_E_DISABLE 0x00000000 -#define TLB_WORD2_UX_MASK 0x00000020 -#define TLB_WORD2_UX_ENABLE 0x00000020 -#define TLB_WORD2_UX_DISABLE 0x00000000 -#define TLB_WORD2_UW_MASK 0x00000010 -#define TLB_WORD2_UW_ENABLE 0x00000010 -#define TLB_WORD2_UW_DISABLE 0x00000000 -#define TLB_WORD2_UR_MASK 0x00000008 -#define TLB_WORD2_UR_ENABLE 0x00000008 -#define TLB_WORD2_UR_DISABLE 0x00000000 -#define TLB_WORD2_SX_MASK 0x00000004 -#define TLB_WORD2_SX_ENABLE 0x00000004 -#define TLB_WORD2_SX_DISABLE 0x00000000 -#define TLB_WORD2_SW_MASK 0x00000002 -#define TLB_WORD2_SW_ENABLE 0x00000002 -#define TLB_WORD2_SW_DISABLE 0x00000000 -#define TLB_WORD2_SR_MASK 0x00000001 -#define TLB_WORD2_SR_ENABLE 0x00000001 -#define TLB_WORD2_SR_DISABLE 0x00000000 +#define TLB_64KB_ALIGN_MASK 0xFFFFF0000ULL +#define TLB_16KB_ALIGN_MASK 0xFFFFFC000ULL +#define TLB_4KB_ALIGN_MASK 0xFFFFFF000ULL +#define TLB_1KB_ALIGN_MASK 0xFFFFFFC00ULL +#define TLB_256MB_SIZE 0x10000000 +#define TLB_16MB_SIZE 0x01000000 +#define TLB_1MB_SIZE 0x00100000 +#define TLB_256KB_SIZE 0x00040000 +#define TLB_64KB_SIZE 0x00010000 +#define TLB_16KB_SIZE 0x00004000 +#define TLB_4KB_SIZE 0x00001000 +#define TLB_1KB_SIZE 0x00000400 + +#define TLB_WORD0_EPN_MASK 0xFFFFFC00 +#define TLB_WORD0_EPN_ENCODE(n) (((unsigned long) (n)) & 0xFFFFFC00) +#define TLB_WORD0_EPN_DECODE(n) (((unsigned long) (n)) & 0xFFFFFC00) +#define TLB_WORD0_V_MASK 0x00000200 +#define TLB_WORD0_V_ENABLE 0x00000200 +#define TLB_WORD0_V_DISABLE 0x00000000 +#define TLB_WORD0_TS_MASK 0x00000100 +#define TLB_WORD0_TS_1 0x00000100 +#define TLB_WORD0_TS_0 0x00000000 +#define TLB_WORD0_SIZE_MASK 0x000000F0 +#define TLB_WORD0_SIZE_1KB 0x00000000 +#define TLB_WORD0_SIZE_4KB 0x00000010 +#define TLB_WORD0_SIZE_16KB 0x00000020 +#define TLB_WORD0_SIZE_64KB 0x00000030 +#define TLB_WORD0_SIZE_256KB 0x00000040 +#define TLB_WORD0_SIZE_1MB 0x00000050 +#define TLB_WORD0_SIZE_16MB 0x00000070 +#define TLB_WORD0_SIZE_256MB 0x00000090 +#define TLB_WORD0_TPAR_MASK 0x0000000F +#define TLB_WORD0_TPAR_ENCODE(n) ((((unsigned long) (n)) & 0x0F) << 0) +#define TLB_WORD0_TPAR_DECODE(n) ((((unsigned long) (n)) >> 0) & 0x0F) + +#define TLB_WORD1_RPN_MASK 0xFFFFFC00 +#define TLB_WORD1_RPN_ENCODE(n) (((unsigned long) (n)) & 0xFFFFFC00) +#define TLB_WORD1_RPN_DECODE(n) (((unsigned long) (n)) & 0xFFFFFC00) +#define TLB_WORD1_PAR1_MASK 0x00000300 +#define TLB_WORD1_PAR1_ENCODE(n) ((((unsigned long) (n)) & 0x03) << 8) +#define TLB_WORD1_PAR1_DECODE(n) ((((unsigned long) (n)) >> 8) & 0x03) +#define TLB_WORD1_PAR1_0 0x00000000 +#define TLB_WORD1_PAR1_1 0x00000100 +#define TLB_WORD1_PAR1_2 0x00000200 +#define TLB_WORD1_PAR1_3 0x00000300 +#define TLB_WORD1_ERPN_MASK 0x0000000F +#define TLB_WORD1_ERPN_ENCODE(n) ((((unsigned long) (n)) & 0x0F) << 0) +#define TLB_WORD1_ERPN_DECODE(n) ((((unsigned long) (n)) >> 0) & 0x0F) + +#define TLB_WORD2_PAR2_MASK 0xC0000000 +#define TLB_WORD2_PAR2_ENCODE(n) ((((unsigned long) (n)) & 0x03) << 30) +#define TLB_WORD2_PAR2_DECODE(n) ((((unsigned long) (n)) >> 30) & 0x03) +#define TLB_WORD2_PAR2_0 0x00000000 +#define TLB_WORD2_PAR2_1 0x40000000 +#define TLB_WORD2_PAR2_2 0x80000000 +#define TLB_WORD2_PAR2_3 0xC0000000 +#define TLB_WORD2_U0_MASK 0x00008000 +#define TLB_WORD2_U0_ENABLE 0x00008000 +#define TLB_WORD2_U0_DISABLE 0x00000000 +#define TLB_WORD2_U1_MASK 0x00004000 +#define TLB_WORD2_U1_ENABLE 0x00004000 +#define TLB_WORD2_U1_DISABLE 0x00000000 +#define TLB_WORD2_U2_MASK 0x00002000 +#define TLB_WORD2_U2_ENABLE 0x00002000 +#define TLB_WORD2_U2_DISABLE 0x00000000 +#define TLB_WORD2_U3_MASK 0x00001000 +#define TLB_WORD2_U3_ENABLE 0x00001000 +#define TLB_WORD2_U3_DISABLE 0x00000000 +#define TLB_WORD2_W_MASK 0x00000800 +#define TLB_WORD2_W_ENABLE 0x00000800 +#define TLB_WORD2_W_DISABLE 0x00000000 +#define TLB_WORD2_I_MASK 0x00000400 +#define TLB_WORD2_I_ENABLE 0x00000400 +#define TLB_WORD2_I_DISABLE 0x00000000 +#define TLB_WORD2_M_MASK 0x00000200 +#define TLB_WORD2_M_ENABLE 0x00000200 +#define TLB_WORD2_M_DISABLE 0x00000000 +#define TLB_WORD2_G_MASK 0x00000100 +#define TLB_WORD2_G_ENABLE 0x00000100 +#define TLB_WORD2_G_DISABLE 0x00000000 +#define TLB_WORD2_E_MASK 0x00000080 +#define TLB_WORD2_E_ENABLE 0x00000080 +#define TLB_WORD2_E_DISABLE 0x00000000 +#define TLB_WORD2_UX_MASK 0x00000020 +#define TLB_WORD2_UX_ENABLE 0x00000020 +#define TLB_WORD2_UX_DISABLE 0x00000000 +#define TLB_WORD2_UW_MASK 0x00000010 +#define TLB_WORD2_UW_ENABLE 0x00000010 +#define TLB_WORD2_UW_DISABLE 0x00000000 +#define TLB_WORD2_UR_MASK 0x00000008 +#define TLB_WORD2_UR_ENABLE 0x00000008 +#define TLB_WORD2_UR_DISABLE 0x00000000 +#define TLB_WORD2_SX_MASK 0x00000004 +#define TLB_WORD2_SX_ENABLE 0x00000004 +#define TLB_WORD2_SX_DISABLE 0x00000000 +#define TLB_WORD2_SW_MASK 0x00000002 +#define TLB_WORD2_SW_ENABLE 0x00000002 +#define TLB_WORD2_SW_DISABLE 0x00000000 +#define TLB_WORD2_SR_MASK 0x00000001 +#define TLB_WORD2_SR_ENABLE 0x00000001 +#define TLB_WORD2_SR_DISABLE 0x00000000 /*----------------------------------------------------------------------------+ | Following instructions are not available in Book E mode of the GNU assembler. +----------------------------------------------------------------------------*/ -#define DCCCI(ra, rb) .long 0x7c000000 | \ - (ra << 16) | (rb << 11) | (454 << 1) +#define DCCCI(ra, rb) .long 0x7c000000 | (ra << 16) | (rb << 11) | (454 << 1) -#define ICCCI(ra, rb) .long 0x7c000000 | \ - (ra << 16) | (rb << 11) | (966 << 1) +#define ICCCI(ra, rb) .long 0x7c000000 | (ra << 16) | (rb << 11) | (966 << 1) #define DCREAD(rt, ra, rb) .long 0x7c000000 | (rt << 21) | (ra << 16) | (rb << 11) | (486 << 1) -#define ICREAD(ra, rb) .long 0x7c000000 | \ - (ra << 16) | (rb << 11) | (998 << 1) +#define ICREAD(ra, rb) .long 0x7c000000 | (ra << 16) | (rb << 11) | (998 << 1) #define TLBSX(rt, ra, rb) .long 0x7c000000 | (rt << 21) | (ra << 16) | (rb << 11) | (914 << 1) @@ -789,17 +766,15 @@ extern int num_tlb_entries; #define TLBSXDOT(rt, ra, rb) .long 0x7c000001 | (rt << 21) | (ra << 16) | (rb << 11) | (914 << 1) -#define MSYNC .long 0x7c000000 | \ - (598 << 1) +#define MSYNC .long 0x7c000000 | (598 << 1) -#define MBAR_INST .long 0x7c000000 | \ - (854 << 1) +#define MBAR_INST .long 0x7c000000 | (854 << 1) #ifndef __ASSEMBLY__ /* Prototypes */ -void mttlb1(unsigned long index, unsigned long value); -void mttlb2(unsigned long index, unsigned long value); -void mttlb3(unsigned long index, unsigned long value); +void mttlb1(unsigned long index, unsigned long value); +void mttlb2(unsigned long index, unsigned long value); +void mttlb3(unsigned long index, unsigned long value); unsigned long mftlb1(unsigned long index); unsigned long mftlb2(unsigned long index); unsigned long mftlb3(unsigned long index); diff --git a/lib/ppc64/processor.h b/lib/ppc64/processor.h index c0d7b03..4c40886 100644 --- a/lib/ppc64/processor.h +++ b/lib/ppc64/processor.h @@ -5,15 +5,19 @@ * Default implementation of macro that returns current * instruction pointer ("program counter"). */ -#define current_text_addr() ({ __label__ _l; _l: &&_l; }) +#define current_text_addr() \ + ({ \ + __label__ _l; \ + _l: \ + &&_l; \ + }) #define AAA_HACK_DISABLE #ifdef AAA_HACK_DISABLE /* warning this is just to make the compiler shut up.. It does not match the definition in ptrace.h. So dont use this code. */ -struct pt_regs -{ - unsigned long nip; +struct pt_regs { + unsigned long nip; }; #else @@ -24,38 +28,38 @@ struct pt_regs /* Machine State Register (MSR) Fields */ #ifdef CONFIG_PPC64BRIDGE -#define MSR_SF (1 << 63) +#define MSR_SF (1 << 63) #define MSR_ISF (1 << 61) -#endif /* CONFIG_PPC64BRIDGE */ +#endif /* CONFIG_PPC64BRIDGE */ #define MSR_UCLE (1 << 26) /* User-mode cache lock enable (e500) */ -#define MSR_VEC (1 << 25) /* Enable AltiVec(74xx) */ -#define MSR_SPE (1 << 25) /* Enable SPE(e500) */ -#define MSR_POW (1 << 18) /* Enable Power Management */ -#define MSR_WE (1 << 18) /* Wait State Enable */ +#define MSR_VEC (1 << 25) /* Enable AltiVec(74xx) */ +#define MSR_SPE (1 << 25) /* Enable SPE(e500) */ +#define MSR_POW (1 << 18) /* Enable Power Management */ +#define MSR_WE (1 << 18) /* Wait State Enable */ #define MSR_TGPR (1 << 17) /* TLB Update registers in use */ -#define MSR_CE (1 << 17) /* Critical Interrupt Enable */ -#define MSR_ILE (1 << 16) /* Interrupt Little Endian */ -#define MSR_EE (1 << 15) /* External Interrupt Enable */ -#define MSR_PR (1 << 14) /* Problem State / Privilege Level */ -#define MSR_FP (1 << 13) /* Floating Point enable */ -#define MSR_ME (1 << 12) /* Machine Check Enable */ -#define MSR_FE0 (1 << 11) /* Floating Exception mode 0 */ -#define MSR_SE (1 << 10) /* Single Step */ -#define MSR_DWE (1 << 10) /* Debug Wait Enable (4xx) */ +#define MSR_CE (1 << 17) /* Critical Interrupt Enable */ +#define MSR_ILE (1 << 16) /* Interrupt Little Endian */ +#define MSR_EE (1 << 15) /* External Interrupt Enable */ +#define MSR_PR (1 << 14) /* Problem State / Privilege Level */ +#define MSR_FP (1 << 13) /* Floating Point enable */ +#define MSR_ME (1 << 12) /* Machine Check Enable */ +#define MSR_FE0 (1 << 11) /* Floating Exception mode 0 */ +#define MSR_SE (1 << 10) /* Single Step */ +#define MSR_DWE (1 << 10) /* Debug Wait Enable (4xx) */ #define MSR_UBLE (1 << 10) /* BTB lock enable (e500) */ -#define MSR_BE (1 << 9) /* Branch Trace */ -#define MSR_DE (1 << 9) /* Debug Exception Enable */ -#define MSR_FE1 (1 << 8) /* Floating Exception mode 1 */ -#define MSR_IP (1 << 6) /* Exception prefix 0x000/0xFFF */ -#define MSR_IR (1 << 5) /* Instruction Relocate */ -#define MSR_IS (1 << 5) /* Book E Instruction space */ -#define MSR_DR (1 << 4) /* Data Relocate */ -#define MSR_DS (1 << 4) /* Book E Data space */ -#define MSR_PE (1 << 3) /* Protection Enable */ -#define MSR_PX (1 << 2) /* Protection Exclusive Mode */ -#define MSR_PMM (1 << 2) /* Performance monitor mark bit (e500) */ -#define MSR_RI (1 << 1) /* Recoverable Exception */ -#define MSR_LE (1 << 0) /* Little Endian */ +#define MSR_BE (1 << 9) /* Branch Trace */ +#define MSR_DE (1 << 9) /* Debug Exception Enable */ +#define MSR_FE1 (1 << 8) /* Floating Exception mode 1 */ +#define MSR_IP (1 << 6) /* Exception prefix 0x000/0xFFF */ +#define MSR_IR (1 << 5) /* Instruction Relocate */ +#define MSR_IS (1 << 5) /* Book E Instruction space */ +#define MSR_DR (1 << 4) /* Data Relocate */ +#define MSR_DS (1 << 4) /* Book E Data space */ +#define MSR_PE (1 << 3) /* Protection Enable */ +#define MSR_PX (1 << 2) /* Protection Exclusive Mode */ +#define MSR_PMM (1 << 2) /* Performance monitor mark bit (e500) */ +#define MSR_RI (1 << 1) /* Recoverable Exception */ +#define MSR_LE (1 << 0) /* Little Endian */ #ifdef CONFIG_APUS_FAST_EXCEPT #define MSR_ MSR_ME | MSR_IP | MSR_RI @@ -70,33 +74,33 @@ struct pt_regs /* Floating Point Status and Control Register (FPSCR) Fields */ -#define FPSCR_FX 0x80000000 /* FPU exception summary */ -#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */ -#define FPSCR_VX 0x20000000 /* Invalid operation summary */ -#define FPSCR_OX 0x10000000 /* Overflow exception summary */ -#define FPSCR_UX 0x08000000 /* Underflow exception summary */ -#define FPSCR_ZX 0x04000000 /* Zero-devide exception summary */ -#define FPSCR_XX 0x02000000 /* Inexact exception summary */ +#define FPSCR_FX 0x80000000 /* FPU exception summary */ +#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */ +#define FPSCR_VX 0x20000000 /* Invalid operation summary */ +#define FPSCR_OX 0x10000000 /* Overflow exception summary */ +#define FPSCR_UX 0x08000000 /* Underflow exception summary */ +#define FPSCR_ZX 0x04000000 /* Zero-devide exception summary */ +#define FPSCR_XX 0x02000000 /* Inexact exception summary */ #define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */ -#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */ -#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */ -#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */ -#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */ -#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */ -#define FPSCR_FR 0x00040000 /* Fraction rounded */ -#define FPSCR_FI 0x00020000 /* Fraction inexact */ -#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */ -#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */ +#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */ +#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */ +#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */ +#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */ +#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */ +#define FPSCR_FR 0x00040000 /* Fraction rounded */ +#define FPSCR_FI 0x00020000 /* Fraction inexact */ +#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */ +#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */ #define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */ #define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */ -#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */ -#define FPSCR_VE 0x00000080 /* Invalid op exception enable */ -#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */ -#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */ -#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */ -#define FPSCR_XE 0x00000008 /* FP inexact exception enable */ -#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */ -#define FPSCR_RN 0x00000003 /* FPU rounding control */ +#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */ +#define FPSCR_VE 0x00000080 /* Invalid op exception enable */ +#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */ +#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */ +#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */ +#define FPSCR_XE 0x00000008 /* FP inexact exception enable */ +#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */ +#define FPSCR_RN 0x00000003 /* FPU rounding control */ /* Special Purpose Registers (SPRNs)*/ @@ -110,99 +114,99 @@ struct pt_regs #define SPRN_CCR1 0x378 /* Core Configuration Register for 440 only */ #endif #define SPRN_CDBCR 0x3D7 /* Cache Debug Control Register */ -#define SPRN_CTR 0x009 /* Count Register */ -#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ +#define SPRN_CTR 0x009 /* Count Register */ +#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ #ifndef CONFIG_BOOKE #define SPRN_DAC1 0x3F6 /* Data Address Compare 1 */ #define SPRN_DAC2 0x3F7 /* Data Address Compare 2 */ #else -#define SPRN_DAC1 0x13C /* Book E Data Address Compare 1 */ -#define SPRN_DAC2 0x13D /* Book E Data Address Compare 2 */ -#endif /* CONFIG_BOOKE */ -#define SPRN_DAR 0x013 /* Data Address Register */ -#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */ -#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */ -#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */ -#define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */ -#define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */ -#define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */ -#define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */ -#define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */ -#define SPRN_DBAT4L 0x239 /* Data BAT 4 Lower Register */ -#define SPRN_DBAT4U 0x238 /* Data BAT 4 Upper Register */ -#define SPRN_DBAT5L 0x23B /* Data BAT 5 Lower Register */ -#define SPRN_DBAT5U 0x23A /* Data BAT 5 Upper Register */ -#define SPRN_DBAT6L 0x23D /* Data BAT 6 Lower Register */ -#define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */ -#define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */ -#define SPRN_DBAT7U 0x23E /* Data BAT 7 Lower Register */ -#define SPRN_DBCR 0x3F2 /* Debug Control Regsiter */ -#define DBCR_EDM 0x80000000 -#define DBCR_IDM 0x40000000 -#define DBCR_RST(x) (((x)&0x3) << 28) -#define DBCR_RST_NONE 0 -#define DBCR_RST_CORE 1 -#define DBCR_RST_CHIP 2 +#define SPRN_DAC1 0x13C /* Book E Data Address Compare 1 */ +#define SPRN_DAC2 0x13D /* Book E Data Address Compare 2 */ +#endif /* CONFIG_BOOKE */ +#define SPRN_DAR 0x013 /* Data Address Register */ +#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */ +#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */ +#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */ +#define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */ +#define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */ +#define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */ +#define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */ +#define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */ +#define SPRN_DBAT4L 0x239 /* Data BAT 4 Lower Register */ +#define SPRN_DBAT4U 0x238 /* Data BAT 4 Upper Register */ +#define SPRN_DBAT5L 0x23B /* Data BAT 5 Lower Register */ +#define SPRN_DBAT5U 0x23A /* Data BAT 5 Upper Register */ +#define SPRN_DBAT6L 0x23D /* Data BAT 6 Lower Register */ +#define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */ +#define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */ +#define SPRN_DBAT7U 0x23E /* Data BAT 7 Lower Register */ +#define SPRN_DBCR 0x3F2 /* Debug Control Regsiter */ +#define DBCR_EDM 0x80000000 +#define DBCR_IDM 0x40000000 +#define DBCR_RST(x) (((x) & 0x3) << 28) +#define DBCR_RST_NONE 0 +#define DBCR_RST_CORE 1 +#define DBCR_RST_CHIP 2 #define DBCR_RST_SYSTEM 3 -#define DBCR_IC 0x08000000 /* Instruction Completion Debug Evnt */ -#define DBCR_BT 0x04000000 /* Branch Taken Debug Event */ -#define DBCR_EDE 0x02000000 /* Exception Debug Event */ -#define DBCR_TDE 0x01000000 /* TRAP Debug Event */ -#define DBCR_FER 0x00F80000 /* First Events Remaining Mask */ -#define DBCR_FT 0x00040000 /* Freeze Timers on Debug Event */ -#define DBCR_IA1 0x00020000 /* Instr. Addr. Compare 1 Enable */ -#define DBCR_IA2 0x00010000 /* Instr. Addr. Compare 2 Enable */ -#define DBCR_D1R 0x00008000 /* Data Addr. Compare 1 Read Enable */ -#define DBCR_D1W 0x00004000 /* Data Addr. Compare 1 Write Enable */ -#define DBCR_D1S(x) (((x)&0x3) << 12) /* Data Adrr. Compare 1 Size */ -#define DAC_BYTE 0 -#define DAC_HALF 1 -#define DAC_WORD 2 -#define DAC_QUAD 3 -#define DBCR_D2R 0x00000800 /* Data Addr. Compare 2 Read Enable */ -#define DBCR_D2W 0x00000400 /* Data Addr. Compare 2 Write Enable */ -#define DBCR_D2S(x) (((x)&0x3) << 8) /* Data Addr. Compare 2 Size */ -#define DBCR_SBT 0x00000040 /* Second Branch Taken Debug Event */ -#define DBCR_SED 0x00000020 /* Second Exception Debug Event */ -#define DBCR_STD 0x00000010 /* Second Trap Debug Event */ -#define DBCR_SIA 0x00000008 /* Second IAC Enable */ -#define DBCR_SDA 0x00000004 /* Second DAC Enable */ -#define DBCR_JOI 0x00000002 /* JTAG Serial Outbound Int. Enable */ -#define DBCR_JII 0x00000001 /* JTAG Serial Inbound Int. Enable */ +#define DBCR_IC 0x08000000 /* Instruction Completion Debug Evnt */ +#define DBCR_BT 0x04000000 /* Branch Taken Debug Event */ +#define DBCR_EDE 0x02000000 /* Exception Debug Event */ +#define DBCR_TDE 0x01000000 /* TRAP Debug Event */ +#define DBCR_FER 0x00F80000 /* First Events Remaining Mask */ +#define DBCR_FT 0x00040000 /* Freeze Timers on Debug Event */ +#define DBCR_IA1 0x00020000 /* Instr. Addr. Compare 1 Enable */ +#define DBCR_IA2 0x00010000 /* Instr. Addr. Compare 2 Enable */ +#define DBCR_D1R 0x00008000 /* Data Addr. Compare 1 Read Enable */ +#define DBCR_D1W 0x00004000 /* Data Addr. Compare 1 Write Enable */ +#define DBCR_D1S(x) (((x) & 0x3) << 12) /* Data Adrr. Compare 1 Size */ +#define DAC_BYTE 0 +#define DAC_HALF 1 +#define DAC_WORD 2 +#define DAC_QUAD 3 +#define DBCR_D2R 0x00000800 /* Data Addr. Compare 2 Read Enable */ +#define DBCR_D2W 0x00000400 /* Data Addr. Compare 2 Write Enable */ +#define DBCR_D2S(x) (((x) & 0x3) << 8) /* Data Addr. Compare 2 Size */ +#define DBCR_SBT 0x00000040 /* Second Branch Taken Debug Event */ +#define DBCR_SED 0x00000020 /* Second Exception Debug Event */ +#define DBCR_STD 0x00000010 /* Second Trap Debug Event */ +#define DBCR_SIA 0x00000008 /* Second IAC Enable */ +#define DBCR_SDA 0x00000004 /* Second DAC Enable */ +#define DBCR_JOI 0x00000002 /* JTAG Serial Outbound Int. Enable */ +#define DBCR_JII 0x00000001 /* JTAG Serial Inbound Int. Enable */ #ifndef CONFIG_BOOKE #define SPRN_DBCR0 0x3F2 /* Debug Control Register 0 */ #else #define SPRN_DBCR0 0x134 /* Book E Debug Control Register 0 */ -#endif /* CONFIG_BOOKE */ +#endif /* CONFIG_BOOKE */ #ifndef CONFIG_BOOKE #define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */ -#define SPRN_DBSR 0x3F0 /* Debug Status Register */ +#define SPRN_DBSR 0x3F0 /* Debug Status Register */ #else #define SPRN_DBCR1 0x135 /* Book E Debug Control Register 1 */ #ifdef CONFIG_BOOKE #define SPRN_DBDR 0x3f3 /* Debug Data Register */ #endif -#define SPRN_DBSR 0x130 /* Book E Debug Status Register */ -#define DBSR_IC 0x08000000 /* Book E Instruction Completion */ -#define DBSR_TIE 0x01000000 /* Book E Trap Instruction Event */ -#endif /* CONFIG_BOOKE */ -#define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */ -#define DCCR_NOCACHE 0 /* Noncacheable */ -#define DCCR_CACHE 1 /* Cacheable */ +#define SPRN_DBSR 0x130 /* Book E Debug Status Register */ +#define DBSR_IC 0x08000000 /* Book E Instruction Completion */ +#define DBSR_TIE 0x01000000 /* Book E Trap Instruction Event */ +#endif /* CONFIG_BOOKE */ +#define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */ +#define DCCR_NOCACHE 0 /* Noncacheable */ +#define DCCR_CACHE 1 /* Cacheable */ #ifndef CONFIG_BOOKE #define SPRN_DCDBTRL 0x39c /* Data Cache Debug Tag Register Low */ #define SPRN_DCDBTRH 0x39d /* Data Cache Debug Tag Register High */ #endif -#define SPRN_DCMP 0x3D1 /* Data TLB Compare Register */ -#define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */ -#define DCWR_COPY 0 /* Copy-back */ -#define DCWR_WRITE 1 /* Write-through */ +#define SPRN_DCMP 0x3D1 /* Data TLB Compare Register */ +#define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */ +#define DCWR_COPY 0 /* Copy-back */ +#define DCWR_WRITE 1 /* Write-through */ #ifndef CONFIG_BOOKE #define SPRN_DEAR 0x3D5 /* Data Error Address Register */ #else -#define SPRN_DEAR 0x03D /* Book E Data Error Address Register */ -#endif /* CONFIG_BOOKE */ -#define SPRN_DEC 0x016 /* Decrement Register */ +#define SPRN_DEAR 0x03D /* Book E Data Error Address Register */ +#endif /* CONFIG_BOOKE */ +#define SPRN_DEC 0x016 /* Decrement Register */ #define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */ #ifdef CONFIG_BOOKE #define SPRN_DNV0 0x390 /* Data Cache Normal Victim 0 */ @@ -212,122 +216,122 @@ struct pt_regs #endif #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ #ifdef CONFIG_BOOKE -#define SPRN_DTV0 0x394 /* Data Cache Transient Victim 0 */ -#define SPRN_DTV1 0x395 /* Data Cache Transient Victim 1 */ -#define SPRN_DTV2 0x396 /* Data Cache Transient Victim 2 */ -#define SPRN_DTV3 0x397 /* Data Cache Transient Victim 3 */ +#define SPRN_DTV0 0x394 /* Data Cache Transient Victim 0 */ +#define SPRN_DTV1 0x395 /* Data Cache Transient Victim 1 */ +#define SPRN_DTV2 0x396 /* Data Cache Transient Victim 2 */ +#define SPRN_DTV3 0x397 /* Data Cache Transient Victim 3 */ #define SPRN_DVLIM 0x398 /* Data Cache Victim Limit */ #endif #define SPRN_EAR 0x11A /* External Address Register */ #ifndef CONFIG_BOOKE #define SPRN_ESR 0x3D4 /* Exception Syndrome Register */ #else -#define SPRN_ESR 0x03E /* Book E Exception Syndrome Register */ -#endif /* CONFIG_BOOKE */ -#define ESR_IMCP 0x80000000 /* Instr. Machine Check - Protection */ -#define ESR_IMCN 0x40000000 /* Instr. Machine Check - Non-config */ -#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ -#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ -#define ESR_PIL 0x08000000 /* Program Exception - Illegal */ -#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ -#define ESR_PTR 0x02000000 /* Program Exception - Trap */ -#define ESR_DST 0x00800000 /* Storage Exception - Data miss */ -#define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */ -#define SPRN_EVPR 0x3D6 /* Exception Vector Prefix Register */ -#define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ -#define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */ -#define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ - -#define HID0_ICE_SHIFT 15 -#define HID0_DCE_SHIFT 14 +#define SPRN_ESR 0x03E /* Book E Exception Syndrome Register */ +#endif /* CONFIG_BOOKE */ +#define ESR_IMCP 0x80000000 /* Instr. Machine Check - Protection */ +#define ESR_IMCN 0x40000000 /* Instr. Machine Check - Non-config */ +#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ +#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ +#define ESR_PIL 0x08000000 /* Program Exception - Illegal */ +#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ +#define ESR_PTR 0x02000000 /* Program Exception - Trap */ +#define ESR_DST 0x00800000 /* Storage Exception - Data miss */ +#define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */ +#define SPRN_EVPR 0x3D6 /* Exception Vector Prefix Register */ +#define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ +#define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */ +#define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ + +#define HID0_ICE_SHIFT 15 +#define HID0_DCE_SHIFT 14 #define HID0_DLOCK_SHIFT 12 -#define HID0_EMCP (1 << 31) /* Enable Machine Check pin */ -#define HID0_EBA (1 << 29) /* Enable Bus Address Parity */ -#define HID0_EBD (1 << 28) /* Enable Bus Data Parity */ -#define HID0_SBCLK (1 << 27) -#define HID0_EICE (1 << 26) -#define HID0_ECLK (1 << 25) -#define HID0_PAR (1 << 24) -#define HID0_DOZE (1 << 23) -#define HID0_NAP (1 << 22) -#define HID0_SLEEP (1 << 21) -#define HID0_DPM (1 << 20) -#define HID0_ICE (1 << HID0_ICE_SHIFT) /* Instruction Cache Enable */ -#define HID0_DCE (1 << HID0_DCE_SHIFT) /* Data Cache Enable */ -#define HID0_TBEN (1 << 14) /* Time Base Enable */ -#define HID0_ILOCK (1 << 13) /* Instruction Cache Lock */ -#define HID0_DLOCK (1 << HID0_DLOCK_SHIFT) /* Data Cache Lock */ -#define HID0_ICFI (1 << 11) /* Instr. Cache Flash Invalidate */ -#define HID0_DCFI (1 << 10) /* Data Cache Flash Invalidate */ -#define HID0_DCI HID0_DCFI -#define HID0_SPD (1 << 9) /* Speculative disable */ -#define HID0_ENMAS7 (1 << 7) /* Enable MAS7 Update for 36-bit phys */ -#define HID0_SGE (1 << 7) /* Store Gathering Enable */ -#define HID0_SIED HID_SGE /* Serial Instr. Execution [Disable] */ -#define HID0_DCFA (1 << 6) /* Data Cache Flush Assist */ -#define HID0_BTIC (1 << 5) /* Branch Target Instruction Cache Enable */ -#define HID0_ABE (1 << 3) /* Address Broadcast Enable */ -#define HID0_BHTE (1 << 2) /* Branch History Table Enable */ -#define HID0_BTCD (1 << 1) /* Branch target cache disable */ -#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ -#define HID1_RFXE (1 << 17) /* Read Fault Exception Enable */ -#define HID1_ASTME (1 << 13) /* Address bus streaming mode */ -#define HID1_ABE (1 << 12) /* Address broadcast enable */ -#define HID1_MBDD (1 << 6) /* optimized sync instruction */ -#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ +#define HID0_EMCP (1 << 31) /* Enable Machine Check pin */ +#define HID0_EBA (1 << 29) /* Enable Bus Address Parity */ +#define HID0_EBD (1 << 28) /* Enable Bus Data Parity */ +#define HID0_SBCLK (1 << 27) +#define HID0_EICE (1 << 26) +#define HID0_ECLK (1 << 25) +#define HID0_PAR (1 << 24) +#define HID0_DOZE (1 << 23) +#define HID0_NAP (1 << 22) +#define HID0_SLEEP (1 << 21) +#define HID0_DPM (1 << 20) +#define HID0_ICE (1 << HID0_ICE_SHIFT) /* Instruction Cache Enable */ +#define HID0_DCE (1 << HID0_DCE_SHIFT) /* Data Cache Enable */ +#define HID0_TBEN (1 << 14) /* Time Base Enable */ +#define HID0_ILOCK (1 << 13) /* Instruction Cache Lock */ +#define HID0_DLOCK (1 << HID0_DLOCK_SHIFT) /* Data Cache Lock */ +#define HID0_ICFI (1 << 11) /* Instr. Cache Flash Invalidate */ +#define HID0_DCFI (1 << 10) /* Data Cache Flash Invalidate */ +#define HID0_DCI HID0_DCFI +#define HID0_SPD (1 << 9) /* Speculative disable */ +#define HID0_ENMAS7 (1 << 7) /* Enable MAS7 Update for 36-bit phys */ +#define HID0_SGE (1 << 7) /* Store Gathering Enable */ +#define HID0_SIED HID_SGE /* Serial Instr. Execution [Disable] */ +#define HID0_DCFA (1 << 6) /* Data Cache Flush Assist */ +#define HID0_BTIC (1 << 5) /* Branch Target Instruction Cache Enable */ +#define HID0_ABE (1 << 3) /* Address Broadcast Enable */ +#define HID0_BHTE (1 << 2) /* Branch History Table Enable */ +#define HID0_BTCD (1 << 1) /* Branch target cache disable */ +#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ +#define HID1_RFXE (1 << 17) /* Read Fault Exception Enable */ +#define HID1_ASTME (1 << 13) /* Address bus streaming mode */ +#define HID1_ABE (1 << 12) /* Address broadcast enable */ +#define HID1_MBDD (1 << 6) /* optimized sync instruction */ +#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ #ifndef CONFIG_BOOKE #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ #define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ #else -#define SPRN_IAC1 0x138 /* Book E Instruction Address Compare 1 */ -#define SPRN_IAC2 0x139 /* Book E Instruction Address Compare 2 */ -#endif /* CONFIG_BOOKE */ -#define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */ -#define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */ -#define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */ -#define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */ -#define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */ -#define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */ -#define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */ -#define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */ -#define SPRN_IBAT4L 0x231 /* Instruction BAT 4 Lower Register */ -#define SPRN_IBAT4U 0x230 /* Instruction BAT 4 Upper Register */ -#define SPRN_IBAT5L 0x233 /* Instruction BAT 5 Lower Register */ -#define SPRN_IBAT5U 0x232 /* Instruction BAT 5 Upper Register */ -#define SPRN_IBAT6L 0x235 /* Instruction BAT 6 Lower Register */ -#define SPRN_IBAT6U 0x234 /* Instruction BAT 6 Upper Register */ -#define SPRN_IBAT7L 0x237 /* Instruction BAT 7 Lower Register */ -#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */ -#define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */ -#define ICCR_NOCACHE 0 /* Noncacheable */ -#define ICCR_CACHE 1 /* Cacheable */ -#define SPRN_ICDBDR 0x3D3 /* Instruction Cache Debug Data Register */ +#define SPRN_IAC1 0x138 /* Book E Instruction Address Compare 1 */ +#define SPRN_IAC2 0x139 /* Book E Instruction Address Compare 2 */ +#endif /* CONFIG_BOOKE */ +#define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */ +#define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */ +#define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */ +#define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */ +#define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */ +#define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */ +#define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */ +#define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */ +#define SPRN_IBAT4L 0x231 /* Instruction BAT 4 Lower Register */ +#define SPRN_IBAT4U 0x230 /* Instruction BAT 4 Upper Register */ +#define SPRN_IBAT5L 0x233 /* Instruction BAT 5 Lower Register */ +#define SPRN_IBAT5U 0x232 /* Instruction BAT 5 Upper Register */ +#define SPRN_IBAT6L 0x235 /* Instruction BAT 6 Lower Register */ +#define SPRN_IBAT6U 0x234 /* Instruction BAT 6 Upper Register */ +#define SPRN_IBAT7L 0x237 /* Instruction BAT 7 Lower Register */ +#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */ +#define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */ +#define ICCR_NOCACHE 0 /* Noncacheable */ +#define ICCR_CACHE 1 /* Cacheable */ +#define SPRN_ICDBDR 0x3D3 /* Instruction Cache Debug Data Register */ #ifdef CONFIG_BOOKE #define SPRN_ICDBTRL 0x39e /* instruction cache debug tag register low */ #define SPRN_ICDBTRH 0x39f /* instruction cache debug tag register high */ #endif -#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ -#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ +#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ +#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ #define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */ -#define SPRN_IMMR 0x27E /* Internal Memory Map Register */ +#define SPRN_IMMR 0x27E /* Internal Memory Map Register */ #ifdef CONFIG_BOOKE -#define SPRN_INV0 0x370 /* Instruction Cache Normal Victim 0 */ -#define SPRN_INV1 0x371 /* Instruction Cache Normal Victim 1 */ -#define SPRN_INV2 0x372 /* Instruction Cache Normal Victim 2 */ -#define SPRN_INV3 0x373 /* Instruction Cache Normal Victim 3 */ -#define SPRN_ITV0 0x374 /* Instruction Cache Transient Victim 0 */ -#define SPRN_ITV1 0x375 /* Instruction Cache Transient Victim 1 */ -#define SPRN_ITV2 0x376 /* Instruction Cache Transient Victim 2 */ -#define SPRN_ITV3 0x377 /* Instruction Cache Transient Victim 3 */ +#define SPRN_INV0 0x370 /* Instruction Cache Normal Victim 0 */ +#define SPRN_INV1 0x371 /* Instruction Cache Normal Victim 1 */ +#define SPRN_INV2 0x372 /* Instruction Cache Normal Victim 2 */ +#define SPRN_INV3 0x373 /* Instruction Cache Normal Victim 3 */ +#define SPRN_ITV0 0x374 /* Instruction Cache Transient Victim 0 */ +#define SPRN_ITV1 0x375 /* Instruction Cache Transient Victim 1 */ +#define SPRN_ITV2 0x376 /* Instruction Cache Transient Victim 2 */ +#define SPRN_ITV3 0x377 /* Instruction Cache Transient Victim 3 */ #define SPRN_IVLIM 0x399 /* Instruction Cache Victim Limit */ #endif #define SPRN_LDSTCR 0x3F8 /* Load/Store Control Register */ -#define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ -#define SPRN_LR 0x008 /* Link Register */ -#define SPRN_MBAR 0x137 /* System memory base address */ -#define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */ -#define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */ +#define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ +#define SPRN_LR 0x008 /* Link Register */ +#define SPRN_MBAR 0x137 /* System memory base address */ +#define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */ +#define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */ #ifdef CONFIG_BOOKE #define SPRN_MMUCR 0x3b2 /* MMU Control Register */ #endif @@ -339,37 +343,37 @@ struct pt_regs #define SPRN_PID 0x3B1 /* Process ID */ #define SPRN_PIR 0x3FF /* Processor Identification Register */ #else -#define SPRN_PID 0x030 /* Book E Process ID */ -#define SPRN_PIR 0x11E /* Book E Processor Identification Register */ -#endif /* CONFIG_BOOKE */ -#define SPRN_PIT 0x3DB /* Programmable Interval Timer */ +#define SPRN_PID 0x030 /* Book E Process ID */ +#define SPRN_PIR 0x11E /* Book E Processor Identification Register */ +#endif /* CONFIG_BOOKE */ +#define SPRN_PIT 0x3DB /* Programmable Interval Timer */ #define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */ #define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */ #define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */ #define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */ -#define SPRN_PVR 0x11F /* Processor Version Register */ -#define SPRN_RPA 0x3D6 /* Required Physical Address Register */ +#define SPRN_PVR 0x11F /* Processor Version Register */ +#define SPRN_RPA 0x3D6 /* Required Physical Address Register */ #ifdef CONFIG_BOOKE #define SPRN_RSTCFG 0x39b /* Reset Configuration */ #endif -#define SPRN_SDA 0x3BF /* Sampled Data Address Register */ -#define SPRN_SDR1 0x019 /* MMU Hash Base Register */ -#define SPRN_SGR 0x3B9 /* Storage Guarded Register */ -#define SGR_NORMAL 0 +#define SPRN_SDA 0x3BF /* Sampled Data Address Register */ +#define SPRN_SDR1 0x019 /* MMU Hash Base Register */ +#define SPRN_SGR 0x3B9 /* Storage Guarded Register */ +#define SGR_NORMAL 0 #define SGR_GUARDED 1 -#define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ -#define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ -#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ -#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */ -#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ -#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ -#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ -#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ -#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ -#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ -#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ -#define SPRN_SRR2 0x3DE /* Save/Restore Register 2 */ -#define SPRN_SRR3 0x3DF /* Save/Restore Register 3 */ +#define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ +#define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ +#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ +#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */ +#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ +#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ +#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ +#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ +#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ +#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ +#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ +#define SPRN_SRR2 0x3DE /* Save/Restore Register 2 */ +#define SPRN_SRR3 0x3DF /* Save/Restore Register 3 */ #ifdef CONFIG_BOOKE #define SPRN_SVR 0x3FF /* System Version Register */ @@ -388,210 +392,209 @@ struct pt_regs #define SPRN_TCR 0x3DA /* Timer Control Register */ #else #define SPRN_TCR 0x154 /* Book E Timer Control Register */ -#endif /* CONFIG_BOOKE */ +#endif /* CONFIG_BOOKE */ #ifdef CONFIG_E500MC -#define TCR_WP(x) (((64 - x) & 0x3) << 30) | \ - (((64 - x) & 0x3c) << 15) /* WDT Period 2^x clocks*/ +#define TCR_WP(x) (((64 - x) & 0x3) << 30) | (((64 - x) & 0x3c) << 15) /* WDT Period 2^x clocks*/ #else -#define TCR_WP(x) (((x)&0x3) << 30) /* WDT Period */ -#define WP_2_17 0 /* 2^17 clocks */ -#define WP_2_21 1 /* 2^21 clocks */ -#define WP_2_25 2 /* 2^25 clocks */ -#define WP_2_29 3 /* 2^29 clocks */ -#endif /* CONFIG_E500 */ -#define TCR_WRC(x) (((x)&0x3) << 28) /* WDT Reset Control */ -#define WRC_NONE 0 /* No reset will occur */ -#define WRC_CORE 1 /* Core reset will occur */ -#define WRC_CHIP 2 /* Chip reset will occur */ -#define WRC_SYSTEM 3 /* System reset will occur */ -#define TCR_WIE 0x08000000 /* WDT Interrupt Enable */ -#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ -#define TCR_FP(x) (((x)&0x3) << 24) /* FIT Period */ -#define FP_2_9 0 /* 2^9 clocks */ -#define FP_2_13 1 /* 2^13 clocks */ -#define FP_2_17 2 /* 2^17 clocks */ -#define FP_2_21 3 /* 2^21 clocks */ -#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ -#define TCR_ARE 0x00400000 /* Auto Reload Enable */ -#define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ -#define THRM1_TIN (1 << 0) -#define THRM1_TIV (1 << 1) -#define THRM1_THRES (0x7f << 2) -#define THRM1_TID (1 << 29) -#define THRM1_TIE (1 << 30) -#define THRM1_V (1 << 31) -#define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ -#define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ -#define THRM3_E (1 << 31) +#define TCR_WP(x) (((x) & 0x3) << 30) /* WDT Period */ +#define WP_2_17 0 /* 2^17 clocks */ +#define WP_2_21 1 /* 2^21 clocks */ +#define WP_2_25 2 /* 2^25 clocks */ +#define WP_2_29 3 /* 2^29 clocks */ +#endif /* CONFIG_E500 */ +#define TCR_WRC(x) (((x) & 0x3) << 28) /* WDT Reset Control */ +#define WRC_NONE 0 /* No reset will occur */ +#define WRC_CORE 1 /* Core reset will occur */ +#define WRC_CHIP 2 /* Chip reset will occur */ +#define WRC_SYSTEM 3 /* System reset will occur */ +#define TCR_WIE 0x08000000 /* WDT Interrupt Enable */ +#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ +#define TCR_FP(x) (((x) & 0x3) << 24) /* FIT Period */ +#define FP_2_9 0 /* 2^9 clocks */ +#define FP_2_13 1 /* 2^13 clocks */ +#define FP_2_17 2 /* 2^17 clocks */ +#define FP_2_21 3 /* 2^21 clocks */ +#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ +#define TCR_ARE 0x00400000 /* Auto Reload Enable */ +#define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ +#define THRM1_TIN (1 << 0) +#define THRM1_TIV (1 << 1) +#define THRM1_THRES (0x7f << 2) +#define THRM1_TID (1 << 29) +#define THRM1_TIE (1 << 30) +#define THRM1_V (1 << 31) +#define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ +#define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ +#define THRM3_E (1 << 31) #define SPRN_TLBMISS 0x3D4 /* 980 7450 TLB Miss Register */ #ifndef CONFIG_BOOKE #define SPRN_TSR 0x3D8 /* Timer Status Register */ #else -#define SPRN_TSR 0x150 /* Book E Timer Status Register */ -#endif /* CONFIG_BOOKE */ -#define TSR_ENW 0x80000000 /* Enable Next Watchdog */ -#define TSR_WIS 0x40000000 /* WDT Interrupt Status */ -#define TSR_WRS(x) (((x)&0x3) << 28) /* WDT Reset Status */ -#define WRS_NONE 0 /* No WDT reset occurred */ -#define WRS_CORE 1 /* WDT forced core reset */ -#define WRS_CHIP 2 /* WDT forced chip reset */ -#define WRS_SYSTEM 3 /* WDT forced system reset */ -#define TSR_PIS 0x08000000 /* PIT Interrupt Status */ -#define TSR_FIS 0x04000000 /* FIT Interrupt Status */ -#define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */ -#define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */ -#define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */ -#define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */ -#define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */ -#define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */ -#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ -#define SPRN_XER 0x001 /* Fixed Point Exception Register */ -#define SPRN_ZPR 0x3B0 /* Zone Protection Register */ +#define SPRN_TSR 0x150 /* Book E Timer Status Register */ +#endif /* CONFIG_BOOKE */ +#define TSR_ENW 0x80000000 /* Enable Next Watchdog */ +#define TSR_WIS 0x40000000 /* WDT Interrupt Status */ +#define TSR_WRS(x) (((x) & 0x3) << 28) /* WDT Reset Status */ +#define WRS_NONE 0 /* No WDT reset occurred */ +#define WRS_CORE 1 /* WDT forced core reset */ +#define WRS_CHIP 2 /* WDT forced chip reset */ +#define WRS_SYSTEM 3 /* WDT forced system reset */ +#define TSR_PIS 0x08000000 /* PIT Interrupt Status */ +#define TSR_FIS 0x04000000 /* FIT Interrupt Status */ +#define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */ +#define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */ +#define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */ +#define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */ +#define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */ +#define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */ +#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ +#define SPRN_XER 0x001 /* Fixed Point Exception Register */ +#define SPRN_ZPR 0x3B0 /* Zone Protection Register */ /* Book E definitions */ -#define SPRN_DECAR 0x036 /* Decrementer Auto Reload Register */ -#define SPRN_CSRR0 0x03A /* Critical SRR0 */ -#define SPRN_CSRR1 0x03B /* Critical SRR0 */ -#define SPRN_IVPR 0x03F /* Interrupt Vector Prefix Register */ -#define SPRN_USPRG0 0x100 /* User Special Purpose Register General 0 */ -#define SPRN_SPRG4R 0x104 /* Special Purpose Register General 4 Read */ -#define SPRN_SPRG5R 0x105 /* Special Purpose Register General 5 Read */ -#define SPRN_SPRG6R 0x106 /* Special Purpose Register General 6 Read */ -#define SPRN_SPRG7R 0x107 /* Special Purpose Register General 7 Read */ -#define SPRN_SPRG4W 0x114 /* Special Purpose Register General 4 Write */ -#define SPRN_SPRG5W 0x115 /* Special Purpose Register General 5 Write */ -#define SPRN_SPRG6W 0x116 /* Special Purpose Register General 6 Write */ -#define SPRN_SPRG7W 0x117 /* Special Purpose Register General 7 Write */ -#define SPRN_DBCR2 0x136 /* Debug Control Register 2 */ -#define SPRN_IAC3 0x13A /* Instruction Address Compare 3 */ -#define SPRN_IAC4 0x13B /* Instruction Address Compare 4 */ -#define SPRN_DVC1 0x13E /* Data Value Compare Register 1 */ -#define SPRN_DVC2 0x13F /* Data Value Compare Register 2 */ -#define SPRN_IVOR0 0x190 /* Interrupt Vector Offset Register 0 */ -#define SPRN_IVOR1 0x191 /* Interrupt Vector Offset Register 1 */ -#define SPRN_IVOR2 0x192 /* Interrupt Vector Offset Register 2 */ -#define SPRN_IVOR3 0x193 /* Interrupt Vector Offset Register 3 */ -#define SPRN_IVOR4 0x194 /* Interrupt Vector Offset Register 4 */ -#define SPRN_IVOR5 0x195 /* Interrupt Vector Offset Register 5 */ -#define SPRN_IVOR6 0x196 /* Interrupt Vector Offset Register 6 */ -#define SPRN_IVOR7 0x197 /* Interrupt Vector Offset Register 7 */ -#define SPRN_IVOR8 0x198 /* Interrupt Vector Offset Register 8 */ -#define SPRN_IVOR9 0x199 /* Interrupt Vector Offset Register 9 */ -#define SPRN_IVOR10 0x19a /* Interrupt Vector Offset Register 10 */ -#define SPRN_IVOR11 0x19b /* Interrupt Vector Offset Register 11 */ -#define SPRN_IVOR12 0x19c /* Interrupt Vector Offset Register 12 */ -#define SPRN_IVOR13 0x19d /* Interrupt Vector Offset Register 13 */ -#define SPRN_IVOR14 0x19e /* Interrupt Vector Offset Register 14 */ -#define SPRN_IVOR15 0x19f /* Interrupt Vector Offset Register 15 */ -#define SPRN_IVOR38 0x1b0 /* Interrupt Vector Offset Register 38 */ -#define SPRN_IVOR39 0x1b1 /* Interrupt Vector Offset Register 39 */ -#define SPRN_IVOR40 0x1b2 /* Interrupt Vector Offset Register 40 */ -#define SPRN_IVOR41 0x1b3 /* Interrupt Vector Offset Register 41 */ -#define SPRN_GIVOR2 0x1b8 /* Guest Interrupt Vector Offset Register 2 */ -#define SPRN_GIVOR3 0x1b9 /* Guest Interrupt Vector Offset Register 3 */ -#define SPRN_GIVOR4 0x1ba /* Guest Interrupt Vector Offset Register 4 */ -#define SPRN_GIVOR8 0x1bb /* Guest Interrupt Vector Offset Register 8 */ +#define SPRN_DECAR 0x036 /* Decrementer Auto Reload Register */ +#define SPRN_CSRR0 0x03A /* Critical SRR0 */ +#define SPRN_CSRR1 0x03B /* Critical SRR0 */ +#define SPRN_IVPR 0x03F /* Interrupt Vector Prefix Register */ +#define SPRN_USPRG0 0x100 /* User Special Purpose Register General 0 */ +#define SPRN_SPRG4R 0x104 /* Special Purpose Register General 4 Read */ +#define SPRN_SPRG5R 0x105 /* Special Purpose Register General 5 Read */ +#define SPRN_SPRG6R 0x106 /* Special Purpose Register General 6 Read */ +#define SPRN_SPRG7R 0x107 /* Special Purpose Register General 7 Read */ +#define SPRN_SPRG4W 0x114 /* Special Purpose Register General 4 Write */ +#define SPRN_SPRG5W 0x115 /* Special Purpose Register General 5 Write */ +#define SPRN_SPRG6W 0x116 /* Special Purpose Register General 6 Write */ +#define SPRN_SPRG7W 0x117 /* Special Purpose Register General 7 Write */ +#define SPRN_DBCR2 0x136 /* Debug Control Register 2 */ +#define SPRN_IAC3 0x13A /* Instruction Address Compare 3 */ +#define SPRN_IAC4 0x13B /* Instruction Address Compare 4 */ +#define SPRN_DVC1 0x13E /* Data Value Compare Register 1 */ +#define SPRN_DVC2 0x13F /* Data Value Compare Register 2 */ +#define SPRN_IVOR0 0x190 /* Interrupt Vector Offset Register 0 */ +#define SPRN_IVOR1 0x191 /* Interrupt Vector Offset Register 1 */ +#define SPRN_IVOR2 0x192 /* Interrupt Vector Offset Register 2 */ +#define SPRN_IVOR3 0x193 /* Interrupt Vector Offset Register 3 */ +#define SPRN_IVOR4 0x194 /* Interrupt Vector Offset Register 4 */ +#define SPRN_IVOR5 0x195 /* Interrupt Vector Offset Register 5 */ +#define SPRN_IVOR6 0x196 /* Interrupt Vector Offset Register 6 */ +#define SPRN_IVOR7 0x197 /* Interrupt Vector Offset Register 7 */ +#define SPRN_IVOR8 0x198 /* Interrupt Vector Offset Register 8 */ +#define SPRN_IVOR9 0x199 /* Interrupt Vector Offset Register 9 */ +#define SPRN_IVOR10 0x19a /* Interrupt Vector Offset Register 10 */ +#define SPRN_IVOR11 0x19b /* Interrupt Vector Offset Register 11 */ +#define SPRN_IVOR12 0x19c /* Interrupt Vector Offset Register 12 */ +#define SPRN_IVOR13 0x19d /* Interrupt Vector Offset Register 13 */ +#define SPRN_IVOR14 0x19e /* Interrupt Vector Offset Register 14 */ +#define SPRN_IVOR15 0x19f /* Interrupt Vector Offset Register 15 */ +#define SPRN_IVOR38 0x1b0 /* Interrupt Vector Offset Register 38 */ +#define SPRN_IVOR39 0x1b1 /* Interrupt Vector Offset Register 39 */ +#define SPRN_IVOR40 0x1b2 /* Interrupt Vector Offset Register 40 */ +#define SPRN_IVOR41 0x1b3 /* Interrupt Vector Offset Register 41 */ +#define SPRN_GIVOR2 0x1b8 /* Guest Interrupt Vector Offset Register 2 */ +#define SPRN_GIVOR3 0x1b9 /* Guest Interrupt Vector Offset Register 3 */ +#define SPRN_GIVOR4 0x1ba /* Guest Interrupt Vector Offset Register 4 */ +#define SPRN_GIVOR8 0x1bb /* Guest Interrupt Vector Offset Register 8 */ #define SPRN_GIVOR13 0x1bc /* Guest Interrupt Vector Offset Register 13 */ #define SPRN_GIVOR14 0x1bd /* Guest Interrupt Vector Offset Register 14 */ /* e500 definitions */ -#define SPRN_L1CFG0 0x203 /* L1 Cache Configuration Register 0 */ -#define SPRN_L1CFG1 0x204 /* L1 Cache Configuration Register 1 */ -#define SPRN_L2CFG0 0x207 /* L2 Cache Configuration Register 0 */ -#define SPRN_L1CSR0 0x3f2 /* L1 Data Cache Control and Status Register 0 */ -#define L1CSR0_CPE 0x00010000 /* Data Cache Parity Enable */ -#define L1CSR0_CUL 0x00000400 /* (D-)Cache Unable to Lock */ +#define SPRN_L1CFG0 0x203 /* L1 Cache Configuration Register 0 */ +#define SPRN_L1CFG1 0x204 /* L1 Cache Configuration Register 1 */ +#define SPRN_L2CFG0 0x207 /* L2 Cache Configuration Register 0 */ +#define SPRN_L1CSR0 0x3f2 /* L1 Data Cache Control and Status Register 0 */ +#define L1CSR0_CPE 0x00010000 /* Data Cache Parity Enable */ +#define L1CSR0_CUL 0x00000400 /* (D-)Cache Unable to Lock */ #define L1CSR0_DCLFR 0x00000100 /* D-Cache Lock Flash Reset */ -#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */ -#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */ -#define SPRN_L1CSR1 0x3f3 /* L1 Instruction Cache Control and Status Register 1 */ -#define L1CSR1_CPE 0x00010000 /* Instruction Cache Parity Enable */ -#define L1CSR1_ICUL 0x00000400 /* I-Cache Unable to Lock */ +#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */ +#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */ +#define SPRN_L1CSR1 0x3f3 /* L1 Instruction Cache Control and Status Register 1 */ +#define L1CSR1_CPE 0x00010000 /* Instruction Cache Parity Enable */ +#define L1CSR1_ICUL 0x00000400 /* I-Cache Unable to Lock */ #define L1CSR1_ICLFR 0x00000100 /* I-Cache Lock Flash Reset */ -#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */ -#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */ -#define SPRN_L1CSR2 0x25e /* L1 Data Cache Control and Status Register 2 */ -#define L1CSR2_DCWS 0x40000000 /* Data Cache Write Shadow */ -#define SPRN_L2CSR0 0x3f9 /* L2 Data Cache Control and Status Register 0 */ -#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */ -#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity/ECC Enable */ -#define L2CSR0_L2WP 0x1c000000 /* L2 I/D Way Partioning */ -#define L2CSR0_L2CM 0x03000000 /* L2 Cache Coherency Mode */ -#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */ -#define L2CSR0_L2IO 0x00100000 /* L2 Cache Instruction Only */ -#define L2CSR0_L2DO 0x00010000 /* L2 Cache Data Only */ +#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */ +#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */ +#define SPRN_L1CSR2 0x25e /* L1 Data Cache Control and Status Register 2 */ +#define L1CSR2_DCWS 0x40000000 /* Data Cache Write Shadow */ +#define SPRN_L2CSR0 0x3f9 /* L2 Data Cache Control and Status Register 0 */ +#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */ +#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity/ECC Enable */ +#define L2CSR0_L2WP 0x1c000000 /* L2 I/D Way Partioning */ +#define L2CSR0_L2CM 0x03000000 /* L2 Cache Coherency Mode */ +#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */ +#define L2CSR0_L2IO 0x00100000 /* L2 Cache Instruction Only */ +#define L2CSR0_L2DO 0x00010000 /* L2 Cache Data Only */ #define L2CSR0_L2REP 0x00003000 /* L2 Line Replacement Algo */ /* e6500 */ #define L2CSR0_L2REP_SPLRUAGE 0x00000000 /* L2REP Streaming PLRU with Aging */ -#define L2CSR0_L2REP_FIFO 0x00001000 /* L2REP FIFO */ -#define L2CSR0_L2REP_SPLRU 0x00002000 /* L2REP Streaming PLRU */ -#define L2CSR0_L2REP_PLRU 0x00003000 /* L2REP PLRU */ +#define L2CSR0_L2REP_FIFO 0x00001000 /* L2REP FIFO */ +#define L2CSR0_L2REP_SPLRU 0x00002000 /* L2REP Streaming PLRU */ +#define L2CSR0_L2REP_PLRU 0x00003000 /* L2REP PLRU */ #define L2CSR0_L2REP_MODE L2CSR0_L2REP_SPLRUAGE -#define L2CSR0_L2FL 0x00000800 /* L2 Cache Flush */ +#define L2CSR0_L2FL 0x00000800 /* L2 Cache Flush */ #define L2CSR0_L2LFC 0x00000400 /* L2 Cache Lock Flash Clear */ #define L2CSR0_L2LOA 0x00000080 /* L2 Cache Lock Overflow Allocate */ -#define L2CSR0_L2LO 0x00000020 /* L2 Cache Lock Overflow */ -#define SPRN_L2CSR1 0x3fa /* L2 Data Cache Control and Status Register 1 */ +#define L2CSR0_L2LO 0x00000020 /* L2 Cache Lock Overflow */ +#define SPRN_L2CSR1 0x3fa /* L2 Data Cache Control and Status Register 1 */ -#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */ -#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */ +#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */ +#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */ #define TLBnCFG_NENTRY_MASK 0x00000fff -#define SPRN_TLB0PS 0x158 /* TLB 0 Page Size Register */ -#define SPRN_TLB1PS 0x159 /* TLB 1 Page Size Register */ -#define SPRN_MMUCSR0 0x3f4 /* MMU control and status register 0 */ -#define SPRN_MMUCFG 0x3F7 /* MMU Configuration Register */ -#define MMUCFG_MAVN 0x00000003 /* MMU Architecture Version Number */ -#define MMUCFG_MAVN_V1 0x00000000 /* v1.0 */ -#define MMUCFG_MAVN_V2 0x00000001 /* v2.0 */ -#define SPRN_MAS0 0x270 /* MMU Assist Register 0 */ -#define SPRN_MAS1 0x271 /* MMU Assist Register 1 */ -#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */ -#define SPRN_MAS3 0x273 /* MMU Assist Register 3 */ -#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */ -#define SPRN_MAS5 0x275 /* MMU Assist Register 5 */ -#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */ -#define SPRN_MAS7 0x3B0 /* MMU Assist Register 7 */ -#define SPRN_MAS8 0x155 /* MMU Assist Register 8 */ - -#define SPRN_IVOR32 0x210 /* Interrupt Vector Offset Register 32 */ -#define SPRN_IVOR33 0x211 /* Interrupt Vector Offset Register 33 */ -#define SPRN_IVOR34 0x212 /* Interrupt Vector Offset Register 34 */ -#define SPRN_IVOR35 0x213 /* Interrupt Vector Offset Register 35 */ -#define SPRN_IVOR36 0x214 /* Interrupt Vector Offset Register 36 */ -#define SPRN_IVOR37 0x215 /* Interrupt Vector Offset Register 37 */ +#define SPRN_TLB0PS 0x158 /* TLB 0 Page Size Register */ +#define SPRN_TLB1PS 0x159 /* TLB 1 Page Size Register */ +#define SPRN_MMUCSR0 0x3f4 /* MMU control and status register 0 */ +#define SPRN_MMUCFG 0x3F7 /* MMU Configuration Register */ +#define MMUCFG_MAVN 0x00000003 /* MMU Architecture Version Number */ +#define MMUCFG_MAVN_V1 0x00000000 /* v1.0 */ +#define MMUCFG_MAVN_V2 0x00000001 /* v2.0 */ +#define SPRN_MAS0 0x270 /* MMU Assist Register 0 */ +#define SPRN_MAS1 0x271 /* MMU Assist Register 1 */ +#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */ +#define SPRN_MAS3 0x273 /* MMU Assist Register 3 */ +#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */ +#define SPRN_MAS5 0x275 /* MMU Assist Register 5 */ +#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */ +#define SPRN_MAS7 0x3B0 /* MMU Assist Register 7 */ +#define SPRN_MAS8 0x155 /* MMU Assist Register 8 */ + +#define SPRN_IVOR32 0x210 /* Interrupt Vector Offset Register 32 */ +#define SPRN_IVOR33 0x211 /* Interrupt Vector Offset Register 33 */ +#define SPRN_IVOR34 0x212 /* Interrupt Vector Offset Register 34 */ +#define SPRN_IVOR35 0x213 /* Interrupt Vector Offset Register 35 */ +#define SPRN_IVOR36 0x214 /* Interrupt Vector Offset Register 36 */ +#define SPRN_IVOR37 0x215 /* Interrupt Vector Offset Register 37 */ #define SPRN_SPEFSCR 0x200 /* SPE & Embedded FP Status & Control */ -#define SPRN_MCSRR0 0x23a /* Machine Check Save and Restore Register 0 */ -#define SPRN_MCSRR1 0x23b /* Machine Check Save and Restore Register 1 */ -#define SPRN_BUCSR 0x3f5 /* Branch Control and Status Register */ +#define SPRN_MCSRR0 0x23a /* Machine Check Save and Restore Register 0 */ +#define SPRN_MCSRR1 0x23b /* Machine Check Save and Restore Register 1 */ +#define SPRN_BUCSR 0x3f5 /* Branch Control and Status Register */ #define BUCSR_STAC_EN 0x01000000 /* Segment target addr cache enable */ -#define BUCSR_LS_EN 0x00400000 /* Link stack enable */ -#define BUCSR_BBFI 0x00000200 /* Branch buffer flash invalidate */ -#define BUCSR_BPEN 0x00000001 /* Branch prediction enable */ -#define BUCSR_ENABLE (BUCSR_STAC_EN | BUCSR_LS_EN | BUCSR_BBFI | BUCSR_BPEN) -#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */ -#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */ -#define SPRN_PID1 0x279 /* Process ID Register 1 */ -#define SPRN_PID2 0x27a /* Process ID Register 2 */ -#define SPRN_MCSR 0x23c /* Machine Check Syndrome register */ -#define SPRN_MCAR 0x23d /* Machine Check Address register */ -#define MCSR_MCS 0x80000000 /* Machine Check Summary */ -#define MCSR_IB 0x40000000 /* Instruction PLB Error */ +#define BUCSR_LS_EN 0x00400000 /* Link stack enable */ +#define BUCSR_BBFI 0x00000200 /* Branch buffer flash invalidate */ +#define BUCSR_BPEN 0x00000001 /* Branch prediction enable */ +#define BUCSR_ENABLE (BUCSR_STAC_EN | BUCSR_LS_EN | BUCSR_BBFI | BUCSR_BPEN) +#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */ +#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */ +#define SPRN_PID1 0x279 /* Process ID Register 1 */ +#define SPRN_PID2 0x27a /* Process ID Register 2 */ +#define SPRN_MCSR 0x23c /* Machine Check Syndrome register */ +#define SPRN_MCAR 0x23d /* Machine Check Address register */ +#define MCSR_MCS 0x80000000 /* Machine Check Summary */ +#define MCSR_IB 0x40000000 /* Instruction PLB Error */ #if defined(CONFIG_440) #define MCSR_DRB 0x20000000 /* Data Read PLB Error */ #define MCSR_DWB 0x10000000 /* Data Write PLB Error */ #else -#define MCSR_DB 0x20000000 /* Data PLB Error */ -#endif /* defined(CONFIG_440) */ +#define MCSR_DB 0x20000000 /* Data PLB Error */ +#endif /* defined(CONFIG_440) */ #define MCSR_TLBP 0x08000000 /* TLB Parity Error */ -#define MCSR_ICP 0x04000000 /* I-Cache Parity Error */ +#define MCSR_ICP 0x04000000 /* I-Cache Parity Error */ #define MCSR_DCSP 0x02000000 /* D-Cache Search Parity Error */ #define MCSR_DCFP 0x01000000 /* D-Cache Flush Parity Error */ #define MCSR_IMPE 0x00800000 /* Imprecise Machine Check Exception */ -#define ESR_ST 0x00800000 /* Store Operation */ +#define ESR_ST 0x00800000 /* Store Operation */ #if defined(CONFIG_MPC86xx) #define SPRN_MSSCR0 0x3f6 @@ -610,11 +613,11 @@ struct pt_regs /* Short-hand versions for a number of the above SPRNs */ -#define CTR SPRN_CTR /* Counter Register */ -#define DAR SPRN_DAR /* Data Address Register */ -#define DABR SPRN_DABR /* Data Address Breakpoint Register */ -#define DAC1 SPRN_DAC1 /* Data Address Register 1 */ -#define DAC2 SPRN_DAC2 /* Data Address Register 2 */ +#define CTR SPRN_CTR /* Counter Register */ +#define DAR SPRN_DAR /* Data Address Register */ +#define DABR SPRN_DABR /* Data Address Breakpoint Register */ +#define DAC1 SPRN_DAC1 /* Data Address Register 1 */ +#define DAC2 SPRN_DAC2 /* Data Address Register 2 */ #define DBAT0L SPRN_DBAT0L /* Data BAT 0 Lower Register */ #define DBAT0U SPRN_DBAT0U /* Data BAT 0 Upper Register */ #define DBAT1L SPRN_DBAT1L /* Data BAT 1 Lower Register */ @@ -631,22 +634,22 @@ struct pt_regs #define DBAT6U SPRN_DBAT6U /* Data BAT 6 Upper Register */ #define DBAT7L SPRN_DBAT7L /* Data BAT 7 Lower Register */ #define DBAT7U SPRN_DBAT7U /* Data BAT 7 Upper Register */ -#define DBCR0 SPRN_DBCR0 /* Debug Control Register 0 */ -#define DBCR1 SPRN_DBCR1 /* Debug Control Register 1 */ -#define DBSR SPRN_DBSR /* Debug Status Register */ -#define DCMP SPRN_DCMP /* Data TLB Compare Register */ -#define DEC SPRN_DEC /* Decrement Register */ -#define DMISS SPRN_DMISS /* Data TLB Miss Register */ -#define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ -#define EAR SPRN_EAR /* External Address Register */ -#define ESR SPRN_ESR /* Exception Syndrome Register */ -#define HASH1 SPRN_HASH1 /* Primary Hash Address Register */ -#define HASH2 SPRN_HASH2 /* Secondary Hash Address Register */ -#define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ -#define HID1 SPRN_HID1 /* Hardware Implementation Register 1 */ -#define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ -#define IAC1 SPRN_IAC1 /* Instruction Address Register 1 */ -#define IAC2 SPRN_IAC2 /* Instruction Address Register 2 */ +#define DBCR0 SPRN_DBCR0 /* Debug Control Register 0 */ +#define DBCR1 SPRN_DBCR1 /* Debug Control Register 1 */ +#define DBSR SPRN_DBSR /* Debug Status Register */ +#define DCMP SPRN_DCMP /* Data TLB Compare Register */ +#define DEC SPRN_DEC /* Decrement Register */ +#define DMISS SPRN_DMISS /* Data TLB Miss Register */ +#define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ +#define EAR SPRN_EAR /* External Address Register */ +#define ESR SPRN_ESR /* Exception Syndrome Register */ +#define HASH1 SPRN_HASH1 /* Primary Hash Address Register */ +#define HASH2 SPRN_HASH2 /* Secondary Hash Address Register */ +#define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ +#define HID1 SPRN_HID1 /* Hardware Implementation Register 1 */ +#define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ +#define IAC1 SPRN_IAC1 /* Instruction Address Register 1 */ +#define IAC2 SPRN_IAC2 /* Instruction Address Register 2 */ #define IBAT0L SPRN_IBAT0L /* Instruction BAT 0 Lower Register */ #define IBAT0U SPRN_IBAT0U /* Instruction BAT 0 Upper Register */ #define IBAT1L SPRN_IBAT1L /* Instruction BAT 1 Lower Register */ @@ -663,27 +666,27 @@ struct pt_regs #define IBAT6U SPRN_IBAT6U /* Instruction BAT 6 Upper Register */ #define IBAT7L SPRN_IBAT7L /* Instruction BAT 7 Lower Register */ #define IBAT7U SPRN_IBAT7U /* Instruction BAT 7 Lower Register */ -#define ICMP SPRN_ICMP /* Instruction TLB Compare Register */ -#define IMISS SPRN_IMISS /* Instruction TLB Miss Register */ -#define IMMR SPRN_IMMR /* PPC 860/821 Internal Memory Map Register */ +#define ICMP SPRN_ICMP /* Instruction TLB Compare Register */ +#define IMISS SPRN_IMISS /* Instruction TLB Miss Register */ +#define IMMR SPRN_IMMR /* PPC 860/821 Internal Memory Map Register */ #define LDSTCR SPRN_LDSTCR /* Load/Store Control Register */ -#define L2CR SPRN_L2CR /* PPC 750 L2 control register */ -#define LR SPRN_LR -#define MBAR SPRN_MBAR /* System memory base address */ +#define L2CR SPRN_L2CR /* PPC 750 L2 control register */ +#define LR SPRN_LR +#define MBAR SPRN_MBAR /* System memory base address */ #if defined(CONFIG_MPC86xx) #define MSSCR0 SPRN_MSSCR0 #endif #if defined(CONFIG_E500) || defined(CONFIG_MPC86xx) #define PIR SPRN_PIR #endif -#define SVR SPRN_SVR /* System-On-Chip Version Register */ -#define PVR SPRN_PVR /* Processor Version */ -#define RPA SPRN_RPA /* Required Physical Address Register */ -#define SDR1 SPRN_SDR1 /* MMU hash base register */ -#define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ -#define SPR1 SPRN_SPRG1 -#define SPR2 SPRN_SPRG2 -#define SPR3 SPRN_SPRG3 +#define SVR SPRN_SVR /* System-On-Chip Version Register */ +#define PVR SPRN_PVR /* Processor Version */ +#define RPA SPRN_RPA /* Required Physical Address Register */ +#define SDR1 SPRN_SDR1 /* MMU hash base register */ +#define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ +#define SPR1 SPRN_SPRG1 +#define SPR2 SPRN_SPRG2 +#define SPR3 SPRN_SPRG3 #define SPRG0 SPRN_SPRG0 #define SPRG1 SPRN_SPRG1 #define SPRG2 SPRN_SPRG2 @@ -692,87 +695,87 @@ struct pt_regs #define SPRG5 SPRN_SPRG5 #define SPRG6 SPRN_SPRG6 #define SPRG7 SPRN_SPRG7 -#define SRR0 SPRN_SRR0 /* Save and Restore Register 0 */ -#define SRR1 SPRN_SRR1 /* Save and Restore Register 1 */ -#define SRR2 SPRN_SRR2 /* Save and Restore Register 2 */ -#define SRR3 SPRN_SRR3 /* Save and Restore Register 3 */ -#define SVR SPRN_SVR /* System Version Register */ -#define TBRL SPRN_TBRL /* Time Base Read Lower Register */ -#define TBRU SPRN_TBRU /* Time Base Read Upper Register */ -#define TBWL SPRN_TBWL /* Time Base Write Lower Register */ -#define TBWU SPRN_TBWU /* Time Base Write Upper Register */ -#define TCR SPRN_TCR /* Timer Control Register */ -#define TSR SPRN_TSR /* Timer Status Register */ -#define ICTC 1019 +#define SRR0 SPRN_SRR0 /* Save and Restore Register 0 */ +#define SRR1 SPRN_SRR1 /* Save and Restore Register 1 */ +#define SRR2 SPRN_SRR2 /* Save and Restore Register 2 */ +#define SRR3 SPRN_SRR3 /* Save and Restore Register 3 */ +#define SVR SPRN_SVR /* System Version Register */ +#define TBRL SPRN_TBRL /* Time Base Read Lower Register */ +#define TBRU SPRN_TBRU /* Time Base Read Upper Register */ +#define TBWL SPRN_TBWL /* Time Base Write Lower Register */ +#define TBWU SPRN_TBWU /* Time Base Write Upper Register */ +#define TCR SPRN_TCR /* Timer Control Register */ +#define TSR SPRN_TSR /* Timer Status Register */ +#define ICTC 1019 #define THRM1 SPRN_THRM1 /* Thermal Management Register 1 */ #define THRM2 SPRN_THRM2 /* Thermal Management Register 2 */ #define THRM3 SPRN_THRM3 /* Thermal Management Register 3 */ -#define XER SPRN_XER - -#define DECAR SPRN_DECAR -#define CSRR0 SPRN_CSRR0 -#define CSRR1 SPRN_CSRR1 -#define IVPR SPRN_IVPR -#define USPRG0 SPRN_USPRG -#define SPRG4R SPRN_SPRG4R -#define SPRG5R SPRN_SPRG5R -#define SPRG6R SPRN_SPRG6R -#define SPRG7R SPRN_SPRG7R -#define SPRG4W SPRN_SPRG4W -#define SPRG5W SPRN_SPRG5W -#define SPRG6W SPRN_SPRG6W -#define SPRG7W SPRN_SPRG7W -#define DEAR SPRN_DEAR -#define DBCR2 SPRN_DBCR2 -#define IAC3 SPRN_IAC3 -#define IAC4 SPRN_IAC4 -#define DVC1 SPRN_DVC1 -#define DVC2 SPRN_DVC2 -#define IVOR0 SPRN_IVOR0 -#define IVOR1 SPRN_IVOR1 -#define IVOR2 SPRN_IVOR2 -#define IVOR3 SPRN_IVOR3 -#define IVOR4 SPRN_IVOR4 -#define IVOR5 SPRN_IVOR5 -#define IVOR6 SPRN_IVOR6 -#define IVOR7 SPRN_IVOR7 -#define IVOR8 SPRN_IVOR8 -#define IVOR9 SPRN_IVOR9 -#define IVOR10 SPRN_IVOR10 -#define IVOR11 SPRN_IVOR11 -#define IVOR12 SPRN_IVOR12 -#define IVOR13 SPRN_IVOR13 -#define IVOR14 SPRN_IVOR14 -#define IVOR15 SPRN_IVOR15 -#define IVOR32 SPRN_IVOR32 -#define IVOR33 SPRN_IVOR33 -#define IVOR34 SPRN_IVOR34 -#define IVOR35 SPRN_IVOR35 -#define MCSRR0 SPRN_MCSRR0 -#define MCSRR1 SPRN_MCSRR1 -#define L1CSR0 SPRN_L1CSR0 -#define L1CSR1 SPRN_L1CSR1 -#define L1CSR2 SPRN_L1CSR2 -#define L1CFG0 SPRN_L1CFG0 -#define L1CFG1 SPRN_L1CFG1 -#define L2CFG0 SPRN_L2CFG0 -#define L2CSR0 SPRN_L2CSR0 -#define L2CSR1 SPRN_L2CSR1 -#define MCSR SPRN_MCSR +#define XER SPRN_XER + +#define DECAR SPRN_DECAR +#define CSRR0 SPRN_CSRR0 +#define CSRR1 SPRN_CSRR1 +#define IVPR SPRN_IVPR +#define USPRG0 SPRN_USPRG +#define SPRG4R SPRN_SPRG4R +#define SPRG5R SPRN_SPRG5R +#define SPRG6R SPRN_SPRG6R +#define SPRG7R SPRN_SPRG7R +#define SPRG4W SPRN_SPRG4W +#define SPRG5W SPRN_SPRG5W +#define SPRG6W SPRN_SPRG6W +#define SPRG7W SPRN_SPRG7W +#define DEAR SPRN_DEAR +#define DBCR2 SPRN_DBCR2 +#define IAC3 SPRN_IAC3 +#define IAC4 SPRN_IAC4 +#define DVC1 SPRN_DVC1 +#define DVC2 SPRN_DVC2 +#define IVOR0 SPRN_IVOR0 +#define IVOR1 SPRN_IVOR1 +#define IVOR2 SPRN_IVOR2 +#define IVOR3 SPRN_IVOR3 +#define IVOR4 SPRN_IVOR4 +#define IVOR5 SPRN_IVOR5 +#define IVOR6 SPRN_IVOR6 +#define IVOR7 SPRN_IVOR7 +#define IVOR8 SPRN_IVOR8 +#define IVOR9 SPRN_IVOR9 +#define IVOR10 SPRN_IVOR10 +#define IVOR11 SPRN_IVOR11 +#define IVOR12 SPRN_IVOR12 +#define IVOR13 SPRN_IVOR13 +#define IVOR14 SPRN_IVOR14 +#define IVOR15 SPRN_IVOR15 +#define IVOR32 SPRN_IVOR32 +#define IVOR33 SPRN_IVOR33 +#define IVOR34 SPRN_IVOR34 +#define IVOR35 SPRN_IVOR35 +#define MCSRR0 SPRN_MCSRR0 +#define MCSRR1 SPRN_MCSRR1 +#define L1CSR0 SPRN_L1CSR0 +#define L1CSR1 SPRN_L1CSR1 +#define L1CSR2 SPRN_L1CSR2 +#define L1CFG0 SPRN_L1CFG0 +#define L1CFG1 SPRN_L1CFG1 +#define L2CFG0 SPRN_L2CFG0 +#define L2CSR0 SPRN_L2CSR0 +#define L2CSR1 SPRN_L2CSR1 +#define MCSR SPRN_MCSR #define MMUCSR0 SPRN_MMUCSR0 -#define BUCSR SPRN_BUCSR -#define PID0 SPRN_PID -#define PID1 SPRN_PID1 -#define PID2 SPRN_PID2 -#define MAS0 SPRN_MAS0 -#define MAS1 SPRN_MAS1 -#define MAS2 SPRN_MAS2 -#define MAS3 SPRN_MAS3 -#define MAS4 SPRN_MAS4 -#define MAS5 SPRN_MAS5 -#define MAS6 SPRN_MAS6 -#define MAS7 SPRN_MAS7 -#define MAS8 SPRN_MAS8 +#define BUCSR SPRN_BUCSR +#define PID0 SPRN_PID +#define PID1 SPRN_PID1 +#define PID2 SPRN_PID2 +#define MAS0 SPRN_MAS0 +#define MAS1 SPRN_MAS1 +#define MAS2 SPRN_MAS2 +#define MAS3 SPRN_MAS3 +#define MAS4 SPRN_MAS4 +#define MAS5 SPRN_MAS5 +#define MAS6 SPRN_MAS6 +#define MAS7 SPRN_MAS7 +#define MAS8 SPRN_MAS8 #if defined(CONFIG_4xx) || defined(CONFIG_44x) || defined(CONFIG_MPC85xx) #define DAR_DEAR DEAR @@ -782,92 +785,92 @@ struct pt_regs /* Device Control Registers */ -#define DCRN_BEAR 0x090 /* Bus Error Address Register */ -#define DCRN_BESR 0x091 /* Bus Error Syndrome Register */ -#define BESR_DSES 0x80000000 /* Data-Side Error Status */ -#define BESR_DMES 0x40000000 /* DMA Error Status */ -#define BESR_RWS 0x20000000 /* Read/Write Status */ +#define DCRN_BEAR 0x090 /* Bus Error Address Register */ +#define DCRN_BESR 0x091 /* Bus Error Syndrome Register */ +#define BESR_DSES 0x80000000 /* Data-Side Error Status */ +#define BESR_DMES 0x40000000 /* DMA Error Status */ +#define BESR_RWS 0x20000000 /* Read/Write Status */ #define BESR_ETMASK 0x1C000000 /* Error Type */ -#define ET_PROT 0 -#define ET_PARITY 1 -#define ET_NCFG 2 -#define ET_BUSERR 4 -#define ET_BUSTO 6 -#define DCRN_DMACC0 0x0C4 /* DMA Chained Count Register 0 */ -#define DCRN_DMACC1 0x0CC /* DMA Chained Count Register 1 */ -#define DCRN_DMACC2 0x0D4 /* DMA Chained Count Register 2 */ -#define DCRN_DMACC3 0x0DC /* DMA Chained Count Register 3 */ -#define DCRN_DMACR0 0x0C0 /* DMA Channel Control Register 0 */ -#define DCRN_DMACR1 0x0C8 /* DMA Channel Control Register 1 */ -#define DCRN_DMACR2 0x0D0 /* DMA Channel Control Register 2 */ -#define DCRN_DMACR3 0x0D8 /* DMA Channel Control Register 3 */ -#define DCRN_DMACT0 0x0C1 /* DMA Count Register 0 */ -#define DCRN_DMACT1 0x0C9 /* DMA Count Register 1 */ -#define DCRN_DMACT2 0x0D1 /* DMA Count Register 2 */ -#define DCRN_DMACT3 0x0D9 /* DMA Count Register 3 */ -#define DCRN_DMADA0 0x0C2 /* DMA Destination Address Register 0 */ -#define DCRN_DMADA1 0x0CA /* DMA Destination Address Register 1 */ -#define DCRN_DMADA2 0x0D2 /* DMA Destination Address Register 2 */ -#define DCRN_DMADA3 0x0DA /* DMA Destination Address Register 3 */ -#define DCRN_DMASA0 0x0C3 /* DMA Source Address Register 0 */ -#define DCRN_DMASA1 0x0CB /* DMA Source Address Register 1 */ -#define DCRN_DMASA2 0x0D3 /* DMA Source Address Register 2 */ -#define DCRN_DMASA3 0x0DB /* DMA Source Address Register 3 */ -#define DCRN_DMASR 0x0E0 /* DMA Status Register */ -#define DCRN_EXIER 0x042 /* External Interrupt Enable Register */ -#define EXIER_CIE 0x80000000 /* Critical Interrupt Enable */ -#define EXIER_SRIE 0x08000000 /* Serial Port Rx Int. Enable */ -#define EXIER_STIE 0x04000000 /* Serial Port Tx Int. Enable */ -#define EXIER_JRIE 0x02000000 /* JTAG Serial Port Rx Int. Enable */ -#define EXIER_JTIE 0x01000000 /* JTAG Serial Port Tx Int. Enable */ -#define EXIER_D0IE 0x00800000 /* DMA Channel 0 Interrupt Enable */ -#define EXIER_D1IE 0x00400000 /* DMA Channel 1 Interrupt Enable */ -#define EXIER_D2IE 0x00200000 /* DMA Channel 2 Interrupt Enable */ -#define EXIER_D3IE 0x00100000 /* DMA Channel 3 Interrupt Enable */ -#define EXIER_E0IE 0x00000010 /* External Interrupt 0 Enable */ -#define EXIER_E1IE 0x00000008 /* External Interrupt 1 Enable */ -#define EXIER_E2IE 0x00000004 /* External Interrupt 2 Enable */ -#define EXIER_E3IE 0x00000002 /* External Interrupt 3 Enable */ -#define EXIER_E4IE 0x00000001 /* External Interrupt 4 Enable */ -#define DCRN_EXISR 0x040 /* External Interrupt Status Register */ -#define DCRN_IOCR 0x0A0 /* Input/Output Configuration Register */ -#define IOCR_E0TE 0x80000000 -#define IOCR_E0LP 0x40000000 -#define IOCR_E1TE 0x20000000 -#define IOCR_E1LP 0x10000000 -#define IOCR_E2TE 0x08000000 -#define IOCR_E2LP 0x04000000 -#define IOCR_E3TE 0x02000000 -#define IOCR_E3LP 0x01000000 -#define IOCR_E4TE 0x00800000 -#define IOCR_E4LP 0x00400000 -#define IOCR_EDT 0x00080000 -#define IOCR_SOR 0x00040000 -#define IOCR_EDO 0x00008000 -#define IOCR_2XC 0x00004000 -#define IOCR_ATC 0x00002000 -#define IOCR_SPD 0x00001000 -#define IOCR_BEM 0x00000800 -#define IOCR_PTD 0x00000400 -#define IOCR_ARE 0x00000080 -#define IOCR_DRC 0x00000020 -#define IOCR_RDM(x) (((x)&0x3) << 3) -#define IOCR_TCS 0x00000004 -#define IOCR_SCS 0x00000002 -#define IOCR_SPC 0x00000001 +#define ET_PROT 0 +#define ET_PARITY 1 +#define ET_NCFG 2 +#define ET_BUSERR 4 +#define ET_BUSTO 6 +#define DCRN_DMACC0 0x0C4 /* DMA Chained Count Register 0 */ +#define DCRN_DMACC1 0x0CC /* DMA Chained Count Register 1 */ +#define DCRN_DMACC2 0x0D4 /* DMA Chained Count Register 2 */ +#define DCRN_DMACC3 0x0DC /* DMA Chained Count Register 3 */ +#define DCRN_DMACR0 0x0C0 /* DMA Channel Control Register 0 */ +#define DCRN_DMACR1 0x0C8 /* DMA Channel Control Register 1 */ +#define DCRN_DMACR2 0x0D0 /* DMA Channel Control Register 2 */ +#define DCRN_DMACR3 0x0D8 /* DMA Channel Control Register 3 */ +#define DCRN_DMACT0 0x0C1 /* DMA Count Register 0 */ +#define DCRN_DMACT1 0x0C9 /* DMA Count Register 1 */ +#define DCRN_DMACT2 0x0D1 /* DMA Count Register 2 */ +#define DCRN_DMACT3 0x0D9 /* DMA Count Register 3 */ +#define DCRN_DMADA0 0x0C2 /* DMA Destination Address Register 0 */ +#define DCRN_DMADA1 0x0CA /* DMA Destination Address Register 1 */ +#define DCRN_DMADA2 0x0D2 /* DMA Destination Address Register 2 */ +#define DCRN_DMADA3 0x0DA /* DMA Destination Address Register 3 */ +#define DCRN_DMASA0 0x0C3 /* DMA Source Address Register 0 */ +#define DCRN_DMASA1 0x0CB /* DMA Source Address Register 1 */ +#define DCRN_DMASA2 0x0D3 /* DMA Source Address Register 2 */ +#define DCRN_DMASA3 0x0DB /* DMA Source Address Register 3 */ +#define DCRN_DMASR 0x0E0 /* DMA Status Register */ +#define DCRN_EXIER 0x042 /* External Interrupt Enable Register */ +#define EXIER_CIE 0x80000000 /* Critical Interrupt Enable */ +#define EXIER_SRIE 0x08000000 /* Serial Port Rx Int. Enable */ +#define EXIER_STIE 0x04000000 /* Serial Port Tx Int. Enable */ +#define EXIER_JRIE 0x02000000 /* JTAG Serial Port Rx Int. Enable */ +#define EXIER_JTIE 0x01000000 /* JTAG Serial Port Tx Int. Enable */ +#define EXIER_D0IE 0x00800000 /* DMA Channel 0 Interrupt Enable */ +#define EXIER_D1IE 0x00400000 /* DMA Channel 1 Interrupt Enable */ +#define EXIER_D2IE 0x00200000 /* DMA Channel 2 Interrupt Enable */ +#define EXIER_D3IE 0x00100000 /* DMA Channel 3 Interrupt Enable */ +#define EXIER_E0IE 0x00000010 /* External Interrupt 0 Enable */ +#define EXIER_E1IE 0x00000008 /* External Interrupt 1 Enable */ +#define EXIER_E2IE 0x00000004 /* External Interrupt 2 Enable */ +#define EXIER_E3IE 0x00000002 /* External Interrupt 3 Enable */ +#define EXIER_E4IE 0x00000001 /* External Interrupt 4 Enable */ +#define DCRN_EXISR 0x040 /* External Interrupt Status Register */ +#define DCRN_IOCR 0x0A0 /* Input/Output Configuration Register */ +#define IOCR_E0TE 0x80000000 +#define IOCR_E0LP 0x40000000 +#define IOCR_E1TE 0x20000000 +#define IOCR_E1LP 0x10000000 +#define IOCR_E2TE 0x08000000 +#define IOCR_E2LP 0x04000000 +#define IOCR_E3TE 0x02000000 +#define IOCR_E3LP 0x01000000 +#define IOCR_E4TE 0x00800000 +#define IOCR_E4LP 0x00400000 +#define IOCR_EDT 0x00080000 +#define IOCR_SOR 0x00040000 +#define IOCR_EDO 0x00008000 +#define IOCR_2XC 0x00004000 +#define IOCR_ATC 0x00002000 +#define IOCR_SPD 0x00001000 +#define IOCR_BEM 0x00000800 +#define IOCR_PTD 0x00000400 +#define IOCR_ARE 0x00000080 +#define IOCR_DRC 0x00000020 +#define IOCR_RDM(x) (((x) & 0x3) << 3) +#define IOCR_TCS 0x00000004 +#define IOCR_SCS 0x00000002 +#define IOCR_SPC 0x00000001 /* System-On-Chip Version Register */ /* System-On-Chip Version Register (SVR) field extraction */ #define SVR_VER(svr) (((svr) >> 16) & 0xFFFF) /* Version field */ -#define SVR_REV(svr) (((svr) >> 0) & 0xFF) /* Revision field */ +#define SVR_REV(svr) (((svr) >> 0) & 0xFF) /* Revision field */ -#define SVR_CID(svr) (((svr) >> 28) & 0x0F) /* Company or manufacturer ID */ +#define SVR_CID(svr) (((svr) >> 28) & 0x0F) /* Company or manufacturer ID */ #define SVR_SOCOP(svr) (((svr) >> 22) & 0x3F) /* SOC integration options */ -#define SVR_SID(svr) (((svr) >> 16) & 0x3F) /* SOC ID */ -#define SVR_PROC(svr) (((svr) >> 12) & 0x0F) /* Process revision field */ -#define SVR_MFG(svr) (((svr) >> 8) & 0x0F) /* Manufacturing revision */ +#define SVR_SID(svr) (((svr) >> 16) & 0x3F) /* SOC ID */ +#define SVR_PROC(svr) (((svr) >> 12) & 0x0F) /* Process revision field */ +#define SVR_MFG(svr) (((svr) >> 8) & 0x0F) /* Manufacturing revision */ #define SVR_MJREV(svr) (((svr) >> 4) & 0x0F) /* Major SOC design revision indicator */ #define SVR_MNREV(svr) (((svr) >> 0) & 0x0F) /* Minor SOC design revision indicator */ @@ -883,105 +886,105 @@ struct pt_regs * revision subfields of the PVR for the PowerPC 403s into the following: */ -#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */ -#define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */ -#define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */ -#define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */ -#define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */ -#define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */ +#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */ +#define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */ +#define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */ +#define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */ +#define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */ +#define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */ /* e600 core PVR fields */ -#define PVR_E600_VER(pvr) (((pvr) >> 15) & 0xFFFF) /* Version/type */ -#define PVR_E600_TECH(pvr) (((pvr) >> 12) & 0xF) /* Technology */ -#define PVR_E600_MAJ(pvr) (((pvr) >> 8) & 0xF) /* Major revision */ -#define PVR_E600_MIN(pvr) (((pvr) >> 0) & 0xFF) /* Minor revision */ +#define PVR_E600_VER(pvr) (((pvr) >> 15) & 0xFFFF) /* Version/type */ +#define PVR_E600_TECH(pvr) (((pvr) >> 12) & 0xF) /* Technology */ +#define PVR_E600_MAJ(pvr) (((pvr) >> 8) & 0xF) /* Major revision */ +#define PVR_E600_MIN(pvr) (((pvr) >> 0) & 0xFF) /* Minor revision */ /* Processor Version Numbers */ -#define PVR_403GA 0x00200000 -#define PVR_403GB 0x00200100 -#define PVR_403GC 0x00200200 -#define PVR_403GCX 0x00201400 -#define PVR_405GP 0x40110000 -#define PVR_405GP_RB 0x40110040 -#define PVR_405GP_RC 0x40110082 -#define PVR_405GP_RD 0x401100C4 -#define PVR_405GP_RE 0x40110145 /* same as pc405cr rev c */ -#define PVR_405EP_RA 0x51210950 -#define PVR_405GPR_RB 0x50910951 -#define PVR_405EZ_RA 0x41511460 -#define PVR_405EXR2_RA 0x12911471 /* 405EXr rev A/B without Security */ -#define PVR_405EX1_RA 0x12911477 /* 405EX rev A/B with Security */ -#define PVR_405EXR1_RC 0x1291147B /* 405EXr rev C with Security */ -#define PVR_405EXR2_RC 0x12911479 /* 405EXr rev C without Security */ -#define PVR_405EX1_RC 0x1291147F /* 405EX rev C with Security */ -#define PVR_405EX2_RC 0x1291147D /* 405EX rev C without Security */ -#define PVR_405EXR1_RD 0x12911472 /* 405EXr rev D with Security */ -#define PVR_405EXR2_RD 0x12911470 /* 405EXr rev D without Security */ -#define PVR_405EX1_RD 0x12911475 /* 405EX rev D with Security */ -#define PVR_405EX2_RD 0x12911473 /* 405EX rev D without Security */ -#define PVR_440GP_RB 0x40120440 -#define PVR_440GP_RC 0x40120481 -#define PVR_440EP_RA 0x42221850 -#define PVR_440EP_RB 0x422218D3 /* 440EP rev B and 440GR rev A have same PVR */ -#define PVR_440EP_RC 0x422218D4 /* 440EP rev C and 440GR rev B have same PVR */ -#define PVR_440GR_RA 0x422218D3 /* 440EP rev B and 440GR rev A have same PVR */ -#define PVR_440GR_RB 0x422218D4 /* 440EP rev C and 440GR rev B have same PVR */ -#define PVR_440EPX1_RA 0x216218D0 /* 440EPX rev A with Security / Kasumi */ -#define PVR_440EPX2_RA 0x216218D4 /* 440EPX rev A without Security / Kasumi */ -#define PVR_440GRX1_RA 0x216218D0 /* 440GRX rev A with Security / Kasumi */ -#define PVR_440GRX2_RA 0x216218D4 /* 440GRX rev A without Security / Kasumi */ -#define PVR_440GX_RA 0x51B21850 -#define PVR_440GX_RB 0x51B21851 -#define PVR_440GX_RC 0x51B21892 -#define PVR_440GX_RF 0x51B21894 -#define PVR_405EP_RB 0x51210950 +#define PVR_403GA 0x00200000 +#define PVR_403GB 0x00200100 +#define PVR_403GC 0x00200200 +#define PVR_403GCX 0x00201400 +#define PVR_405GP 0x40110000 +#define PVR_405GP_RB 0x40110040 +#define PVR_405GP_RC 0x40110082 +#define PVR_405GP_RD 0x401100C4 +#define PVR_405GP_RE 0x40110145 /* same as pc405cr rev c */ +#define PVR_405EP_RA 0x51210950 +#define PVR_405GPR_RB 0x50910951 +#define PVR_405EZ_RA 0x41511460 +#define PVR_405EXR2_RA 0x12911471 /* 405EXr rev A/B without Security */ +#define PVR_405EX1_RA 0x12911477 /* 405EX rev A/B with Security */ +#define PVR_405EXR1_RC 0x1291147B /* 405EXr rev C with Security */ +#define PVR_405EXR2_RC 0x12911479 /* 405EXr rev C without Security */ +#define PVR_405EX1_RC 0x1291147F /* 405EX rev C with Security */ +#define PVR_405EX2_RC 0x1291147D /* 405EX rev C without Security */ +#define PVR_405EXR1_RD 0x12911472 /* 405EXr rev D with Security */ +#define PVR_405EXR2_RD 0x12911470 /* 405EXr rev D without Security */ +#define PVR_405EX1_RD 0x12911475 /* 405EX rev D with Security */ +#define PVR_405EX2_RD 0x12911473 /* 405EX rev D without Security */ +#define PVR_440GP_RB 0x40120440 +#define PVR_440GP_RC 0x40120481 +#define PVR_440EP_RA 0x42221850 +#define PVR_440EP_RB 0x422218D3 /* 440EP rev B and 440GR rev A have same PVR */ +#define PVR_440EP_RC 0x422218D4 /* 440EP rev C and 440GR rev B have same PVR */ +#define PVR_440GR_RA 0x422218D3 /* 440EP rev B and 440GR rev A have same PVR */ +#define PVR_440GR_RB 0x422218D4 /* 440EP rev C and 440GR rev B have same PVR */ +#define PVR_440EPX1_RA 0x216218D0 /* 440EPX rev A with Security / Kasumi */ +#define PVR_440EPX2_RA 0x216218D4 /* 440EPX rev A without Security / Kasumi */ +#define PVR_440GRX1_RA 0x216218D0 /* 440GRX rev A with Security / Kasumi */ +#define PVR_440GRX2_RA 0x216218D4 /* 440GRX rev A without Security / Kasumi */ +#define PVR_440GX_RA 0x51B21850 +#define PVR_440GX_RB 0x51B21851 +#define PVR_440GX_RC 0x51B21892 +#define PVR_440GX_RF 0x51B21894 +#define PVR_405EP_RB 0x51210950 #define PVR_440SP_6_RAB 0x53221850 /* 440SP rev A&B with RAID 6 support enabled */ -#define PVR_440SP_RAB 0x53321850 /* 440SP rev A&B without RAID 6 support */ -#define PVR_440SP_6_RC 0x53221891 /* 440SP rev C with RAID 6 support enabled */ -#define PVR_440SP_RC 0x53321891 /* 440SP rev C without RAID 6 support */ +#define PVR_440SP_RAB 0x53321850 /* 440SP rev A&B without RAID 6 support */ +#define PVR_440SP_6_RC 0x53221891 /* 440SP rev C with RAID 6 support enabled */ +#define PVR_440SP_RC 0x53321891 /* 440SP rev C without RAID 6 support */ #define PVR_440SPe_6_RA 0x53421890 /* 440SPe rev A with RAID 6 support enabled */ -#define PVR_440SPe_RA 0x53521890 /* 440SPe rev A without RAID 6 support */ +#define PVR_440SPe_RA 0x53521890 /* 440SPe rev A without RAID 6 support */ #define PVR_440SPe_6_RB 0x53421891 /* 440SPe rev B with RAID 6 support enabled */ -#define PVR_440SPe_RB 0x53521891 /* 440SPe rev B without RAID 6 support */ +#define PVR_440SPe_RB 0x53521891 /* 440SPe rev B without RAID 6 support */ #define PVR_460EX_SE_RA 0x130218A2 /* 460EX rev A with Security Engine */ -#define PVR_460EX_RA 0x130218A3 /* 460EX rev A without Security Engine */ -#define PVR_460EX_RB 0x130218A4 /* 460EX rev B with and without Sec Eng*/ +#define PVR_460EX_RA 0x130218A3 /* 460EX rev A without Security Engine */ +#define PVR_460EX_RB 0x130218A4 /* 460EX rev B with and without Sec Eng*/ #define PVR_460GT_SE_RA 0x130218A0 /* 460GT rev A with Security Engine */ -#define PVR_460GT_RA 0x130218A1 /* 460GT rev A without Security Engine */ -#define PVR_460GT_RB 0x130218A5 /* 460GT rev B with and without Sec Eng*/ -#define PVR_460SX_RA 0x13541800 /* 460SX rev A */ +#define PVR_460GT_RA 0x130218A1 /* 460GT rev A without Security Engine */ +#define PVR_460GT_RB 0x130218A5 /* 460GT rev B with and without Sec Eng*/ +#define PVR_460SX_RA 0x13541800 /* 460SX rev A */ #define PVR_460SX_RA_V1 0x13541801 /* 460SX rev A Variant 1 Security disabled */ -#define PVR_460GX_RA 0x13541802 /* 460GX rev A */ +#define PVR_460GX_RA 0x13541802 /* 460GX rev A */ #define PVR_460GX_RA_V1 0x13541803 /* 460GX rev A Variant 1 Security disabled */ #define PVR_APM821XX_RA 0x12C41C80 /* APM821XX rev A */ -#define PVR_601 0x00010000 -#define PVR_602 0x00050000 -#define PVR_603 0x00030000 -#define PVR_603e 0x00060000 -#define PVR_603ev 0x00070000 -#define PVR_603r 0x00071000 -#define PVR_604 0x00040000 -#define PVR_604e 0x00090000 -#define PVR_604r 0x000A0000 -#define PVR_620 0x00140000 -#define PVR_740 0x00080000 -#define PVR_750 PVR_740 -#define PVR_740P 0x10080000 -#define PVR_750P PVR_740P -#define PVR_7400 0x000C0000 -#define PVR_7410 0x800C0000 -#define PVR_7450 0x80000000 - -#define PVR_85xx 0x80200000 -#define PVR_85xx_REV1 (PVR_85xx | 0x0010) -#define PVR_85xx_REV2 (PVR_85xx | 0x0020) +#define PVR_601 0x00010000 +#define PVR_602 0x00050000 +#define PVR_603 0x00030000 +#define PVR_603e 0x00060000 +#define PVR_603ev 0x00070000 +#define PVR_603r 0x00071000 +#define PVR_604 0x00040000 +#define PVR_604e 0x00090000 +#define PVR_604r 0x000A0000 +#define PVR_620 0x00140000 +#define PVR_740 0x00080000 +#define PVR_750 PVR_740 +#define PVR_740P 0x10080000 +#define PVR_750P PVR_740P +#define PVR_7400 0x000C0000 +#define PVR_7410 0x800C0000 +#define PVR_7450 0x80000000 + +#define PVR_85xx 0x80200000 +#define PVR_85xx_REV1 (PVR_85xx | 0x0010) +#define PVR_85xx_REV2 (PVR_85xx | 0x0020) #define PVR_VER_E500_V1 0x8020 #define PVR_VER_E500_V2 0x8021 -#define PVR_VER_E500MC 0x8023 -#define PVR_VER_E5500 0x8024 -#define PVR_VER_E6500 0x8040 +#define PVR_VER_E500MC 0x8023 +#define PVR_VER_E5500 0x8024 +#define PVR_VER_E6500 0x8040 #define PVR_86xx 0x80040000 @@ -993,10 +996,10 @@ struct pt_regs * differentiated by the version number in the Communication Processor * Module (CPM). */ -#define PVR_821 0x00500000 -#define PVR_823 PVR_821 -#define PVR_850 PVR_821 -#define PVR_860 PVR_821 +#define PVR_821 0x00500000 +#define PVR_823 PVR_821 +#define PVR_850 PVR_821 +#define PVR_860 PVR_821 #define PVR_7400 0x000C0000 #define PVR_8240 0x00810100 @@ -1004,17 +1007,17 @@ struct pt_regs * PowerQUICC II family processors report different PVR values depending * on silicon process (HiP3, HiP4, HiP7, etc.) */ -#define PVR_8260 PVR_8240 -#define PVR_8260_HIP3 0x00810101 -#define PVR_8260_HIP4 0x80811014 -#define PVR_8260_HIP7 0x80822011 +#define PVR_8260 PVR_8240 +#define PVR_8260_HIP3 0x00810101 +#define PVR_8260_HIP4 0x80811014 +#define PVR_8260_HIP7 0x80822011 #define PVR_8260_HIP7R1 0x80822013 #define PVR_8260_HIP7RA 0x80822014 /* * MPC 52xx */ -#define PVR_5200 0x80822011 +#define PVR_5200 0x80822011 #define PVR_5200B 0x80822014 /* @@ -1022,29 +1025,29 @@ struct pt_regs */ #ifdef CONFIG_CB_4xx_CHIP_21_405EX_SECURITY #define CONFIG_CB_4xx_CHIP_21_ERRATA -#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EX1_RC -#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EX1_RD +#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EX1_RC +#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EX1_RD #define CONFIG_405EX_CHIP21_ECID3_REV_D 0x0 #endif #ifdef CONFIG_CB_4xx_CHIP_21_405EX_NO_SECURITY #define CONFIG_CB_4xx_CHIP_21_ERRATA -#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EX2_RC -#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EX2_RD +#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EX2_RC +#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EX2_RD #define CONFIG_405EX_CHIP21_ECID3_REV_D 0x1 #endif #ifdef CONFIG_CB_4xx_CHIP_21_405EXr_SECURITY #define CONFIG_CB_4xx_CHIP_21_ERRATA -#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EXR1_RC -#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EXR1_RD +#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EXR1_RC +#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EXR1_RD #define CONFIG_405EX_CHIP21_ECID3_REV_D 0x2 #endif #ifdef CONFIG_CB_4xx_CHIP_21_405EXr_NO_SECURITY #define CONFIG_CB_4xx_CHIP_21_ERRATA -#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EXR2_RC -#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EXR2_RD +#define CONFIG_405EX_CHIP21_PVR_REV_C PVR_405EXR2_RC +#define CONFIG_405EX_CHIP21_PVR_REV_D PVR_405EXR2_RD #define CONFIG_405EX_CHIP21_ECID3_REV_D 0x3 #endif @@ -1057,7 +1060,7 @@ struct pt_regs #define SVR_SUBVER(svr) (((svr) >> 8) & 0xFF) /* Process/MFG sub-version */ #define SVR_FAM(svr) (((svr) >> 20) & 0xFFF) /* Family field */ -#define SVR_MEM(svr) (((svr) >> 16) & 0xF) /* Member field */ +#define SVR_MEM(svr) (((svr) >> 16) & 0xF) /* Member field */ #ifdef CONFIG_MPC8536 #define SVR_MAJ(svr) (((svr) >> 4) & 0x7) /* Major revision field*/ @@ -1078,29 +1081,28 @@ struct pt_regs #endif #endif -#define IS_SVR_REV(svr, maj, min) \ - ((SVR_MAJ(svr) == maj) && (SVR_MIN(svr) == min)) +#define IS_SVR_REV(svr, maj, min) ((SVR_MAJ(svr) == maj) && (SVR_MIN(svr) == min)) /* * SVR_SOC_VER() Version Values */ -#define SVR_8533 0x803400 -#define SVR_8535 0x803701 -#define SVR_8536 0x803700 -#define SVR_8540 0x803000 -#define SVR_8541 0x807200 -#define SVR_8543 0x803200 -#define SVR_8544 0x803401 -#define SVR_8545 0x803102 -#define SVR_8547 0x803101 -#define SVR_8548 0x803100 -#define SVR_8555 0x807100 -#define SVR_8560 0x807000 -#define SVR_8567 0x807501 -#define SVR_8568 0x807500 -#define SVR_8569 0x808000 -#define SVR_8572 0x80E000 +#define SVR_8533 0x803400 +#define SVR_8535 0x803701 +#define SVR_8536 0x803700 +#define SVR_8540 0x803000 +#define SVR_8541 0x807200 +#define SVR_8543 0x803200 +#define SVR_8544 0x803401 +#define SVR_8545 0x803102 +#define SVR_8547 0x803101 +#define SVR_8548 0x803100 +#define SVR_8555 0x807100 +#define SVR_8560 0x807000 +#define SVR_8567 0x807501 +#define SVR_8568 0x807500 +#define SVR_8569 0x808000 +#define SVR_8572 0x80E000 #define SVR_P1010 0x80F100 #define SVR_P1011 0x80E500 #define SVR_P1012 0x80E501 @@ -1128,9 +1130,9 @@ struct pt_regs #define SVR_T4120 0x824001 #define SVR_T4160 0x824100 #define SVR_T4080 0x824102 -#define SVR_C291 0x850000 -#define SVR_C292 0x850020 -#define SVR_C293 0x850030 +#define SVR_C291 0x850000 +#define SVR_C292 0x850020 +#define SVR_C293 0x850030 #define SVR_B4860 0X868000 #define SVR_G4860 0x868001 #define SVR_B4460 0x868003 @@ -1151,8 +1153,8 @@ struct pt_regs #define SVR_T2080 0x853000 #define SVR_T2081 0x853100 -#define SVR_8610 0x80A000 -#define SVR_8641 0x809000 +#define SVR_8610 0x80A000 +#define SVR_8641 0x809000 #define SVR_8641D 0x809001 #define SVR_9130 0x860001 @@ -1163,50 +1165,52 @@ struct pt_regs #define SVR_Unknown 0xFFFFFF #define _GLOBAL(n) \ - .globl n; \ - n: + .globl n; \ + n: /* Macros for setting and retrieving special purpose registers */ #define stringify(s) tostring(s) -#define tostring(s) #s - -#define mfdcr(rn) ({unsigned int rval; \ - asm volatile("mfdcr %0," stringify(rn) \ - : "=r" (rval)); rval; }) -#define mtdcr(rn, v) asm volatile("mtdcr " stringify(rn) ",%0" \ - : \ - : "r"(v)) - -#define mfmsr() ({unsigned int rval; \ - asm volatile("mfmsr %0" : "=r" (rval)); rval; }) -#define mtmsr(v) asm volatile("mtmsr %0" \ - : \ - : "r"(v)) - -#define mfspr(rn) ({unsigned int rval; \ - asm volatile("mfspr %0," stringify(rn) \ - : "=r" (rval)); rval; }) -#define mtspr(rn, v) asm volatile("mtspr " stringify(rn) ",%0" \ - : \ - : "r"(v)) - -#define tlbie(v) asm volatile("tlbie %0 \n sync" \ - : \ - : "r"(v)) +#define tostring(s) #s + +#define mfdcr(rn) \ + ({ \ + unsigned int rval; \ + asm volatile("mfdcr %0," stringify(rn) : "=r"(rval)); \ + rval; \ + }) +#define mtdcr(rn, v) asm volatile("mtdcr " stringify(rn) ",%0" : : "r"(v)) + +#define mfmsr() \ + ({ \ + unsigned int rval; \ + asm volatile("mfmsr %0" : "=r"(rval)); \ + rval; \ + }) +#define mtmsr(v) asm volatile("mtmsr %0" : : "r"(v)) + +#define mfspr(rn) \ + ({ \ + unsigned int rval; \ + asm volatile("mfspr %0," stringify(rn) : "=r"(rval)); \ + rval; \ + }) +#define mtspr(rn, v) asm volatile("mtspr " stringify(rn) ",%0" : : "r"(v)) + +#define tlbie(v) asm volatile("tlbie %0 \n sync" : : "r"(v)) /* Segment Registers */ -#define SR0 0 -#define SR1 1 -#define SR2 2 -#define SR3 3 -#define SR4 4 -#define SR5 5 -#define SR6 6 -#define SR7 7 -#define SR8 8 -#define SR9 9 +#define SR0 0 +#define SR1 1 +#define SR2 2 +#define SR3 3 +#define SR4 4 +#define SR5 5 +#define SR6 6 +#define SR7 7 +#define SR8 8 +#define SR9 9 #define SR10 10 #define SR11 11 #define SR12 12 @@ -1218,40 +1222,32 @@ struct pt_regs #include <lib/boot.h> -struct cpu_type -{ - char name[15]; - uint32_t soc_ver; - uint32_t num_cores; - uint32_t mask; /* which cpu(s) actually exist */ +struct cpu_type { + char name[15]; + uint32_t soc_ver; + uint32_t num_cores; + uint32_t mask; /* which cpu(s) actually exist */ #ifdef CONFIG_HETROGENOUS_CLUSTERS - uint32_t dsp_num_cores; - uint32_t dsp_mask; /* which DSP cpu(s) actually exist */ + uint32_t dsp_num_cores; + uint32_t dsp_mask; /* which DSP cpu(s) actually exist */ #endif }; struct cpu_type* identify_cpu(uint32_t ver); -int fixup_cpu(void); +int fixup_cpu(void); int fsl_qoriq_core_to_cluster(unsigned int core); int fsl_qoriq_dsp_core_to_cluster(unsigned int core); #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) -#define CPU_TYPE_ENTRY(n, v, nc) \ - { \ - .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), \ - .mask = (1 << (nc)) - 1 \ - } -#define CPU_TYPE_ENTRY_MASK(n, v, nc, m) \ - { \ - .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), .mask = (m) \ - } +#define CPU_TYPE_ENTRY(n, v, nc) \ + { .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), .mask = (1 << (nc)) - 1 } +#define CPU_TYPE_ENTRY_MASK(n, v, nc, m) \ + { .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), .mask = (m) } #else #if defined(CONFIG_MPC83xx) #define CPU_TYPE_ENTRY(x) \ - { \ -#x, SPR_##x \ - } + { #x, SPR_##x } #endif #endif @@ -1282,10 +1278,10 @@ extern long kernel_thread(int (*fn)(void*), void* arg, unsigned long flags); /* * Bus types */ -#define EISA_bus 0 +#define EISA_bus 0 #define EISA_bus__is_a_macro /* for versions in ksyms.c */ -#define MCA_bus 0 -#define MCA_bus__is_a_macro /* for versions in ksyms.c */ +#define MCA_bus 0 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ /* Lazy FPU handling on uni-processor */ extern struct task_struct* last_task_used_math; @@ -1304,73 +1300,63 @@ extern struct task_struct* last_task_used_altivec; */ #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) -typedef struct -{ - unsigned long seg; +typedef struct { + unsigned long seg; } mm_segment_t; -struct thread_struct -{ - unsigned long ksp; /* Kernel stack pointer */ - unsigned long wchan; /* Event task is sleeping on */ - struct pt_regs* regs; /* Pointer to saved register state */ - mm_segment_t fs; /* for get_fs() validation */ - void* pgdir; /* root of page-table tree */ - signed long last_syscall; - double fpr[32]; /* Complete floating point set */ - unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */ - unsigned long fpscr; /* Floating point status */ +struct thread_struct { + unsigned long ksp; /* Kernel stack pointer */ + unsigned long wchan; /* Event task is sleeping on */ + struct pt_regs* regs; /* Pointer to saved register state */ + mm_segment_t fs; /* for get_fs() validation */ + void* pgdir; /* root of page-table tree */ + signed long last_syscall; + double fpr[32]; /* Complete floating point set */ + unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */ + unsigned long fpscr; /* Floating point status */ #ifdef CONFIG_ALTIVEC - vector128 vr[32]; /* Complete AltiVec set */ - vector128 vscr; /* AltiVec status */ - unsigned long vrsave; + vector128 vr[32]; /* Complete AltiVec set */ + vector128 vscr; /* AltiVec status */ + unsigned long vrsave; #endif /* CONFIG_ALTIVEC */ }; -#define INIT_SP (sizeof(init_stack) + (unsigned long)&init_stack) +#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) -#define INIT_THREAD \ - { \ - INIT_SP, /* ksp */ \ - 0, /* wchan */ \ - (struct pt_regs*)INIT_SP - 1, /* regs */ \ - KERNEL_DS, /*fs*/ \ - swapper_pg_dir, /* pgdir */ \ - 0, /* last_syscall */ \ - {0}, 0, 0 \ - } +#define INIT_THREAD \ + { \ + INIT_SP, /* ksp */ \ + 0, /* wchan */ \ + (struct pt_regs*) INIT_SP - 1, /* regs */ \ + KERNEL_DS, /*fs*/ \ + swapper_pg_dir, /* pgdir */ \ + 0, /* last_syscall */ \ + {0}, 0, 0 \ + } /* * Note: the vm_start and vm_end fields here should *not* * be in Kernel space. (Could vm_end == vm_start perhaps?) */ -#define INIT_MMAP \ - { \ - &init_mm, 0, 0x1000, NULL, \ - PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, \ - 1, NULL, NULL \ - } +#define INIT_MMAP \ + { &init_mm, 0, 0x1000, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL } /* * Return saved PC of a blocked thread. For now, this is the "user" PC */ -static inline unsigned long thread_saved_pc(struct thread_struct* t) -{ - return (t->regs) ? t->regs->nip : 0; +static inline unsigned long thread_saved_pc(struct thread_struct* t) { + return (t->regs) ? t->regs->nip : 0; } #define copy_segments(tsk, mm) \ - do \ - { \ - } while (0) + do { \ + } while (0) #define release_segments(mm) \ - do \ - { \ - } while (0) + do { \ + } while (0) #define forget_segments() \ - do \ - { \ - } while (0) + do { \ + } while (0) unsigned long get_wchan(struct task_struct* p); @@ -1381,16 +1367,15 @@ unsigned long get_wchan(struct task_struct* p); * NOTE! The task struct and the stack go together */ #define THREAD_SIZE (2 * PAGE_SIZE) -#define alloc_task_struct() \ - ((struct task_struct*)__get_free_pages(GFP_KERNEL, 1)) -#define free_task_struct(p) free_pages((unsigned long)(p), 1) +#define alloc_task_struct() ((struct task_struct*) __get_free_pages(GFP_KERNEL, 1)) +#define free_task_struct(p) free_pages((unsigned long) (p), 1) #define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count) /* in process.c - for early bootup debug -- Cort */ -int ll_printk(const char*, ...); +int ll_printk(const char*, ...); void ll_puts(const char*); -#define init_task (init_task_union.task) +#define init_task (init_task_union.task) #define init_stack (init_task_union.stack) /* In misc.c */ @@ -1401,13 +1386,13 @@ void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val); #ifdef CONFIG_MACH_SPECIFIC #if defined(CONFIG_8xx) #define _machine _MACH_8xx -#define have_of 0 +#define have_of 0 #elif defined(CONFIG_WALNUT) #define _machine _MACH_walnut -#define have_of 0 +#define have_of 0 #elif defined(CONFIG_MPC8260) #define _machine _MACH_8260 -#define have_of 0 +#define have_of 0 #else #error "Machine not defined correctly" #endif diff --git a/lib/string.h b/lib/string.h index 700ea76..1ea01da 100644 --- a/lib/string.h +++ b/lib/string.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ diff --git a/lib/xcoff.h b/lib/xcoff.h index ed19029..abfa35a 100644 --- a/lib/xcoff.h +++ b/lib/xcoff.h @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. - File: xcoff.h - Purpose: XCOFF for CoreBoot. + File: xcoff.h + Purpose: XCOFF for CoreBoot. - Revision History: + Revision History: - 04/07/24: Added file (amlel) + 04/07/24: Added file (amlel) ------------------------------------------- */ @@ -20,35 +20,33 @@ #define XCOFF_NAME_LEN 256U -#define XCOFF_REL_FLG 0x0001 -#define XCOFF_EXEC_FLG 0x0002 -#define XCOFF_LNNO_FLG 0x0004 +#define XCOFF_REL_FLG 0x0001 +#define XCOFF_EXEC_FLG 0x0002 +#define XCOFF_LNNO_FLG 0x0004 #define XCOFF_SYMNS_FLG 0x0008 /// @brief XCoff identification header. -typedef struct _xcoff_header -{ - uint16_t magic; - uint16_t target; - uint16_t num_secs; - uint32_t timestamp; - uint64_t symptr; - uint32_t numsyms; - uint16_t opthdr; // ?: Number of bytes in optional header +typedef struct _xcoff_header { + uint16_t magic; + uint16_t target; + uint16_t num_secs; + uint32_t timestamp; + uint64_t symptr; + uint32_t numsyms; + uint16_t opthdr; // ?: Number of bytes in optional header } xcoff_header_t; /// @brief This the executable's manifest fork, designed for NeFS. /// @param prop_xml_fork The XML fork of the executable. /// @param dyld_fork The DYLD fork metadata. /// @param code_sign_fork Executable's certificate contained in a fork. -typedef struct _xcoff_fork_header -{ - char prop_xml_fork[XCOFF_NAME_LEN]; - char dyld_fork[XCOFF_NAME_LEN]; - char code_sign_fork[XCOFF_NAME_LEN]; +typedef struct _xcoff_fork_header { + char prop_xml_fork[XCOFF_NAME_LEN]; + char dyld_fork[XCOFF_NAME_LEN]; + char code_sign_fork[XCOFF_NAME_LEN]; } xcoff_fork_header_t; typedef xcoff_header_t xcoff_header64_t; typedef xcoff_header_t xcoff_header32_t; -#endif // ifndef __XCOFF__ +#endif // ifndef __XCOFF__ diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h index dbd27fc..5019eb2 100644 --- a/libfdt/libfdt.h +++ b/libfdt/libfdt.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,129 +10,121 @@ #define FDT_FIRST_SUPPORTED_VERSION (0x02) #define FDT_LAST_COMPATIBLE_VERSION (0x10) -#define FDT_LAST_SUPPORTED_VERSION (0x11) - -#define FDT_ERR_NOTFOUND (1U) -#define FDT_ERR_EXISTS (2U) -#define FDT_ERR_NOSPACE (3U) -#define FDT_ERR_BADOFFSET (4U) -#define FDT_ERR_BADPATH (5U) -#define FDT_ERR_BADPHANDLE (6U) -#define FDT_ERR_BADSTATE (7U) -#define FDT_ERR_TRUNCATED (8U) -#define FDT_ERR_BADMAGIC (9U) -#define FDT_ERR_BADVERSION (10U) +#define FDT_LAST_SUPPORTED_VERSION (0x11) + +#define FDT_ERR_NOTFOUND (1U) +#define FDT_ERR_EXISTS (2U) +#define FDT_ERR_NOSPACE (3U) +#define FDT_ERR_BADOFFSET (4U) +#define FDT_ERR_BADPATH (5U) +#define FDT_ERR_BADPHANDLE (6U) +#define FDT_ERR_BADSTATE (7U) +#define FDT_ERR_TRUNCATED (8U) +#define FDT_ERR_BADMAGIC (9U) +#define FDT_ERR_BADVERSION (10U) #define FDT_ERR_BADSTRUCTURE (11U) -#define FDT_ERR_BADLAYOUT (12U) -#define FDT_ERR_INTERNAL (13U) -#define FDT_ERR_BADNCELLS (14U) -#define FDT_ERR_BADVALUE (15U) -#define FDT_ERR_BADOVERLAY (16U) -#define FDT_ERR_NOPHANDLES (17U) -#define FDT_ERR_BADFLAGS (18U) -#define FDT_ERR_ALIGNMENT (19U) +#define FDT_ERR_BADLAYOUT (12U) +#define FDT_ERR_INTERNAL (13U) +#define FDT_ERR_BADNCELLS (14U) +#define FDT_ERR_BADVALUE (15U) +#define FDT_ERR_BADOVERLAY (16U) +#define FDT_ERR_NOPHANDLES (17U) +#define FDT_ERR_BADFLAGS (18U) +#define FDT_ERR_ALIGNMENT (19U) #define FDT_ERR_MAX (FDT_ERR_ALIGNMENT) #define FDT_MAX_PHANDLE (0xfffffffe) -#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ +#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ #define FDT_TAGSIZE sizeof(fdt32_t) -struct fdt_header -{ - fdt32_t magic; /* magic word FDT_MAGIC */ - fdt32_t totalsize; /* total size of DT block */ - fdt32_t off_dt_struct; /* offset to structure */ - fdt32_t off_dt_strings; /* offset to strings */ - fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ - fdt32_t version; /* format version */ - fdt32_t last_cocb_version; /* last compatible version */ - - /* version 2 fields below */ - fdt32_t boot_cpuid_phys; /* Which physical CPU id we're - booting on */ - /* version 3 fields below */ - fdt32_t size_dt_strings; /* size of the strings block */ - - /* version 17 fields below */ - fdt32_t size_dt_struct; /* size of the structure block */ +struct fdt_header { + fdt32_t magic; /* magic word FDT_MAGIC */ + fdt32_t totalsize; /* total size of DT block */ + fdt32_t off_dt_struct; /* offset to structure */ + fdt32_t off_dt_strings; /* offset to strings */ + fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ + fdt32_t version; /* format version */ + fdt32_t last_cocb_version; /* last compatible version */ + + /* version 2 fields below */ + fdt32_t boot_cpuid_phys; /* Which physical CPU id we're + booting on */ + /* version 3 fields below */ + fdt32_t size_dt_strings; /* size of the strings block */ + + /* version 17 fields below */ + fdt32_t size_dt_struct; /* size of the structure block */ }; -struct fdt_reserve_entry -{ - fdt64_t address; - fdt64_t size; +struct fdt_reserve_entry { + fdt64_t address; + fdt64_t size; }; -struct fdt_node_header -{ - fdt32_t tag; - char name[]; +struct fdt_node_header { + fdt32_t tag; + char name[]; }; -struct fdt_property -{ - fdt32_t tag; - fdt32_t len; - fdt32_t nameoff; - char data[]; +struct fdt_property { + fdt32_t tag; + fdt32_t len; + fdt32_t nameoff; + char data[]; }; const void* fdt_offset_ptr(const void* fdt, int offset, unsigned int checklen); -static inline voidptr_t fdt_offset_ptr_w(const voidptr_t fdt, int32_t offset, uint32_t checklen) -{ - return (voidptr_t)(fdt_offset_ptr(fdt, offset, checklen)); +static inline voidptr_t fdt_offset_ptr_w(const voidptr_t fdt, int32_t offset, uint32_t checklen) { + return (voidptr_t) (fdt_offset_ptr(fdt, offset, checklen)); } /* * External helpers to access words from a device tree blob. */ -static inline uint16_t fdt16_ld(const fdt16_t* p) -{ - const uint8_t* bp = (const uint8_t*)p; +static inline uint16_t fdt16_ld(const fdt16_t* p) { + const uint8_t* bp = (const uint8_t*) p; - return ((uint16_t)bp[0] << 8) | bp[1]; + return ((uint16_t) bp[0] << 8) | bp[1]; } -static inline uint32_t fdt32_ld(const fdt32_t* p) -{ - const uint8_t* bp = (const uint8_t*)p; +static inline uint32_t fdt32_ld(const fdt32_t* p) { + const uint8_t* bp = (const uint8_t*) p; - return ((uint32_t)bp[0] << 24) | ((uint32_t)bp[1] << 16) | ((uint32_t)bp[2] << 8) | bp[3]; + return ((uint32_t) bp[0] << 24) | ((uint32_t) bp[1] << 16) | ((uint32_t) bp[2] << 8) | bp[3]; } -static inline void fdt32_st(void* property, uint32_t value) -{ - uint8_t* bp = (uint8_t*)property; +static inline void fdt32_st(void* property, uint32_t value) { + uint8_t* bp = (uint8_t*) property; - bp[0] = value >> 24; - bp[1] = (value >> 16) & 0xff; - bp[2] = (value >> 8) & 0xff; - bp[3] = value & 0xff; + bp[0] = value >> 24; + bp[1] = (value >> 16) & 0xff; + bp[2] = (value >> 8) & 0xff; + bp[3] = value & 0xff; } -static inline uint64_t fdt64_ld(const fdt64_t* p) -{ - const uint8_t* bp = (const uint8_t*)p; +static inline uint64_t fdt64_ld(const fdt64_t* p) { + const uint8_t* bp = (const uint8_t*) p; - return ((uint64_t)bp[0] << 56) | ((uint64_t)bp[1] << 48) | ((uint64_t)bp[2] << 40) | ((uint64_t)bp[3] << 32) | ((uint64_t)bp[4] << 24) | ((uint64_t)bp[5] << 16) | ((uint64_t)bp[6] << 8) | bp[7]; + return ((uint64_t) bp[0] << 56) | ((uint64_t) bp[1] << 48) | ((uint64_t) bp[2] << 40) | + ((uint64_t) bp[3] << 32) | ((uint64_t) bp[4] << 24) | ((uint64_t) bp[5] << 16) | + ((uint64_t) bp[6] << 8) | bp[7]; } -static inline void fdt64_st(void* property, uint64_t value) -{ - uint8_t* bp = (uint8_t*)property; - - bp[0] = value >> 56; - bp[1] = (value >> 48) & 0xff; - bp[2] = (value >> 40) & 0xff; - bp[3] = (value >> 32) & 0xff; - bp[4] = (value >> 24) & 0xff; - bp[5] = (value >> 16) & 0xff; - bp[6] = (value >> 8) & 0xff; - bp[7] = value & 0xff; +static inline void fdt64_st(void* property, uint64_t value) { + uint8_t* bp = (uint8_t*) property; + + bp[0] = value >> 56; + bp[1] = (value >> 48) & 0xff; + bp[2] = (value >> 40) & 0xff; + bp[3] = (value >> 32) & 0xff; + bp[4] = (value >> 24) & 0xff; + bp[5] = (value >> 16) & 0xff; + bp[6] = (value >> 8) & 0xff; + bp[7] = value & 0xff; } // @@ -155,25 +147,24 @@ int fdt_first_subnode(const void* fdt, int offset); int fdt_next_subnode(const void* fdt, int offset); -#define fdt_get_header(fdt, field) (fdt32_ld(&((const struct fdt_header*)(fdt))->field)) +#define fdt_get_header(fdt, field) (fdt32_ld(&((const struct fdt_header*) (fdt))->field)) -#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) -#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) -#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) -#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) -#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) -#define fdt_version(fdt) (fdt_get_header(fdt, version)) +#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) +#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) +#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) +#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) +#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) +#define fdt_version(fdt) (fdt_get_header(fdt, version)) #define fdt_last_cocb_version(fdt) (fdt_get_header(fdt, last_cocb_version)) -#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) -#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) -#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) +#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) +#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) +#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) #define fdt_set_hdr_(name) \ - static inline void fdt_set_##name(void* fdt, uint32_t val) \ - { \ - struct fdt_header* fdth = (struct fdt_header*)fdt; \ - fdth->name = cpu_to_fdt32(val); \ - } + static inline void fdt_set_##name(void* fdt, uint32_t val) { \ + struct fdt_header* fdth = (struct fdt_header*) fdt; \ + fdth->name = cpu_to_fdt32(val); \ + } fdt_set_hdr_(magic); fdt_set_hdr_(totalsize); diff --git a/libfdt/libfdt_address.c b/libfdt/libfdt_address.c index 8d0af55..a9950dc 100644 --- a/libfdt/libfdt_address.c +++ b/libfdt/libfdt_address.c @@ -1,13 +1,14 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ #include <libfdt/libfdt_env.h> extern fdt32_t* fdt_getprop(const void* fdt, int nodeoffset, const char* name, int* len); -extern fdt32_t* fdt_append_prop(const void* fdt, int nodeoffset, const char* name, uint8_t* data, int32_t len); +extern fdt32_t* fdt_append_prop(const void* fdt, int nodeoffset, const char* name, uint8_t* data, + int32_t len); #ifndef FDT_MAX_NCELLS #define FDT_MAX_NCELLS (4) @@ -25,110 +26,86 @@ extern fdt32_t* fdt_append_prop(const void* fdt, int nodeoffset, const char* nam #define FDT_BAD_VALUE (15) #endif -static int fdt_cells(const void* fdt, int nodeoffset, const char* name) -{ - const fdt32_t* c = null; - uint32_t val = 0; - int len = 0; +static int fdt_cells(const void* fdt, int nodeoffset, const char* name) { + const fdt32_t* c = null; + uint32_t val = 0; + int len = 0; - c = fdt_getprop(fdt, nodeoffset, name, &len); - if (c == null) - return len; + c = fdt_getprop(fdt, nodeoffset, name, &len); + if (c == null) return len; - if (len != sizeof(*c)) - return len; + if (len != sizeof(*c)) return len; - val = fdt32_to_cpu(*c); - if (val > FDT_MAX_NCELLS) - return -FDT_BAD_NCELLS; + val = fdt32_to_cpu(*c); + if (val > FDT_MAX_NCELLS) return -FDT_BAD_NCELLS; - return (int)val; + return (int) val; } -int fdt_address_cells(const void* fdt, int nodeoffset) -{ - int val = 0; - val = fdt_cells(fdt, nodeoffset, "#address-cells"); - if (val == 0) - return -FDT_BAD_NCELLS; +int fdt_address_cells(const void* fdt, int nodeoffset) { + int val = 0; + val = fdt_cells(fdt, nodeoffset, "#address-cells"); + if (val == 0) return -FDT_BAD_NCELLS; - if (val == -FDT_NOT_FOUND) - return 2; + if (val == -FDT_NOT_FOUND) return 2; - return (int)val; + return (int) val; } -int fdt_size_cells(const void* fdt, int nodeoffset) -{ - int val = 0; - val = fdt_cells(fdt, nodeoffset, "#size-cells"); +int fdt_size_cells(const void* fdt, int nodeoffset) { + int val = 0; + val = fdt_cells(fdt, nodeoffset, "#size-cells"); - if (val == -FDT_NOT_FOUND) - return 2; + if (val == -FDT_NOT_FOUND) return 2; - return (int)val; + return (int) val; } -int fdt_append_prop_addr_range(void* fdt, int parent, int nodeoffset, const char* name, uint64_t addr, uint64_t size) -{ - int addr_cells, size_cells, ret; - uint8_t data[sizeof(fdt64_t) * 2], *prop; - - ret = fdt_address_cells(fdt, nodeoffset); - if (ret < 0) - return ret; - - addr_cells = ret; - - ret = fdt_size_cells(fdt, nodeoffset); - if (ret < 0) - return ret; - - size_cells = ret; - - // check address validity - prop = data; - if (addr_cells == 1) - { - // seems to do a check according to two parameters. - // addr > __UINT32_MAX__ detects any out of range addresses? - // ((__UINT32_MAX__ + 1 - addr) < size check if it's lower than it's size - - if ((addr > __UINT32_MAX__) || ((__UINT32_MAX__ + 1 - addr) < size)) - return -FDT_BAD_VALUE; - - // finally set the flat device tree. - fdt32_st(prop, (uint32_t)addr); - } - else if (addr_cells == 2) - { - // no need to check, apparently. - fdt64_st(prop, addr); - } - else - { - return -FDT_BAD_NCELLS; - } - - // access size - prop += addr_cells * sizeof(fdt32_t); - - if (size_cells == 1) - { - if (size > __UINT32_MAX__) - return -FDT_BAD_VALUE; - - fdt32_st(prop, (uint32_t)size); - } - else if (size_cells == 2) - { - fdt64_st(prop, size); - } - else - { - return -FDT_BAD_NCELLS; - } - - return fdt_append_prop(fdt, nodeoffset, name, data, - (addr_cells + size_cells) * sizeof(fdt32_t)); +int fdt_append_prop_addr_range(void* fdt, int parent, int nodeoffset, const char* name, + uint64_t addr, uint64_t size) { + int addr_cells, size_cells, ret; + uint8_t data[sizeof(fdt64_t) * 2], *prop; + + ret = fdt_address_cells(fdt, nodeoffset); + if (ret < 0) return ret; + + addr_cells = ret; + + ret = fdt_size_cells(fdt, nodeoffset); + if (ret < 0) return ret; + + size_cells = ret; + + // check address validity + prop = data; + if (addr_cells == 1) { + // seems to do a check according to two parameters. + // addr > __UINT32_MAX__ detects any out of range addresses? + // ((__UINT32_MAX__ + 1 - addr) < size check if it's lower than it's size + + if ((addr > __UINT32_MAX__) || ((__UINT32_MAX__ + 1 - addr) < size)) return -FDT_BAD_VALUE; + + // finally set the flat device tree. + fdt32_st(prop, (uint32_t) addr); + } else if (addr_cells == 2) { + // no need to check, apparently. + fdt64_st(prop, addr); + } else { + return -FDT_BAD_NCELLS; + } + + // access size + prop += addr_cells * sizeof(fdt32_t); + + if (size_cells == 1) { + if (size > __UINT32_MAX__) return -FDT_BAD_VALUE; + + fdt32_st(prop, (uint32_t) size); + } else if (size_cells == 2) { + fdt64_st(prop, size); + } else { + return -FDT_BAD_NCELLS; + } + + return fdt_append_prop(fdt, nodeoffset, name, data, (addr_cells + size_cells) * sizeof(fdt32_t)); } diff --git a/libfdt/libfdt_empty_tree.c b/libfdt/libfdt_empty_tree.c index 2edfcc2..0cc854f 100644 --- a/libfdt/libfdt_empty_tree.c +++ b/libfdt/libfdt_empty_tree.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -14,8 +14,7 @@ extern int fdt_finish(void* buf); extern int fdt_finish_reverse_map(void* buf); #define fdt_check_err(err) \ - if (err) \ - return err + if (err) return err /** * @brief creates a empty tree with a specified buffer and size. @@ -25,25 +24,24 @@ extern int fdt_finish_reverse_map(void* buf); * @return int */ -int fdt_create_empty_tree(void* buf, int bufsize) -{ - int err; - err = fdt_create(buf, bufsize); - fdt_check_err(err); +int fdt_create_empty_tree(void* buf, int bufsize) { + int err; + err = fdt_create(buf, bufsize); + fdt_check_err(err); - err = fdt_finish_reverse_map(buf); - fdt_check_err(err); + err = fdt_finish_reverse_map(buf); + fdt_check_err(err); - err = fdt_begin_node(buf, ""); - fdt_check_err(err); + err = fdt_begin_node(buf, ""); + fdt_check_err(err); - err = fdt_end_node(buf); - fdt_check_err(err); + err = fdt_end_node(buf); + fdt_check_err(err); - err = fdt_finish(buf); - fdt_check_err(err); + err = fdt_finish(buf); + fdt_check_err(err); - return fdt_open_into(buf, buf, bufsize); + return fdt_open_into(buf, buf, bufsize); } #undef fdt_check_err diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h index bc8f389..6c5616c 100644 --- a/libfdt/libfdt_env.h +++ b/libfdt/libfdt_env.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,7 +10,7 @@ #include <lib/boot.h> #ifdef __USE_SPARSE__ -#define FDT_FORCE __attribute__((force)) +#define FDT_FORCE __attribute__((force)) #define FDT_BITWISE __attribute__((bitwise)) #else #define FDT_FORCE @@ -21,43 +21,38 @@ typedef uint16_t FDT_BITWISE fdt16_t; typedef uint32_t FDT_BITWISE fdt32_t; typedef uint64_t FDT_BITWISE fdt64_t; -#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t*)&x)[n]) -#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) -#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \ - (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3)) -#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \ - (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \ - (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \ - (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7)) - -static inline uint16_t fdt16_to_cpu(fdt16_t x) -{ - return (FDT_FORCE uint16_t)CPU_TO_FDT16(x); +#define EXTRACT_BYTE(x, n) ((unsigned long long) ((uint8_t*) &x)[n]) +#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) +#define CPU_TO_FDT32(x) \ + ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | (EXTRACT_BYTE(x, 2) << 8) | \ + EXTRACT_BYTE(x, 3)) +#define CPU_TO_FDT64(x) \ + ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | (EXTRACT_BYTE(x, 2) << 40) | \ + (EXTRACT_BYTE(x, 3) << 32) | (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \ + (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7)) + +static inline uint16_t fdt16_to_cpu(fdt16_t x) { + return (FDT_FORCE uint16_t) CPU_TO_FDT16(x); } -static inline fdt16_t cpu_to_fdt16(uint16_t x) -{ - return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x); +static inline fdt16_t cpu_to_fdt16(uint16_t x) { + return (FDT_FORCE fdt16_t) CPU_TO_FDT16(x); } -static inline uint32_t fdt32_to_cpu(fdt32_t x) -{ - return (FDT_FORCE uint32_t)CPU_TO_FDT32(x); +static inline uint32_t fdt32_to_cpu(fdt32_t x) { + return (FDT_FORCE uint32_t) CPU_TO_FDT32(x); } -static inline fdt32_t cpu_to_fdt32(uint32_t x) -{ - return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x); +static inline fdt32_t cpu_to_fdt32(uint32_t x) { + return (FDT_FORCE fdt32_t) CPU_TO_FDT32(x); } -static inline uint64_t fdt64_to_cpu(fdt64_t x) -{ - return (FDT_FORCE uint64_t)CPU_TO_FDT64(x); +static inline uint64_t fdt64_to_cpu(fdt64_t x) { + return (FDT_FORCE uint64_t) CPU_TO_FDT64(x); } -static inline fdt64_t cpu_to_fdt64(uint64_t x) -{ - return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x); +static inline fdt64_t cpu_to_fdt64(uint64_t x) { + return (FDT_FORCE fdt64_t) CPU_TO_FDT64(x); } #undef CPU_TO_FDT64 @@ -65,4 +60,4 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x) #undef CPU_TO_FDT16 #undef EXTRACT_BYTE -#endif //!__CB_FDT_H__ +#endif //!__CB_FDT_H__ diff --git a/libfdt/libfdt_strerror.c b/libfdt/libfdt_strerror.c index c4a1abd..accd58a 100644 --- a/libfdt/libfdt_strerror.c +++ b/libfdt/libfdt_strerror.c @@ -1,49 +1,36 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ -#include <libfdt/libfdt_env.h> #include <libfdt/libfdt.h> +#include <libfdt/libfdt_env.h> /***********************************************************************************/ /* @brief FDT error reporting system */ /***********************************************************************************/ /// @brief Error information structure. -struct fdt_err -{ - const char* e_str; +struct fdt_err { + const char* e_str; }; #define fdt_error(VAL) \ - [(VAL)] = { \ - .e_str = #VAL, \ - } + [(VAL)] = { \ + .e_str = #VAL, \ + } static struct fdt_err cb_fdtErrTbl[] = { - fdt_error(FDT_ERR_NOTFOUND), - fdt_error(FDT_ERR_EXISTS), - fdt_error(FDT_ERR_NOSPACE), + fdt_error(FDT_ERR_NOTFOUND), fdt_error(FDT_ERR_EXISTS), fdt_error(FDT_ERR_NOSPACE), - fdt_error(FDT_ERR_BADOFFSET), - fdt_error(FDT_ERR_BADPATH), - fdt_error(FDT_ERR_BADPHANDLE), - fdt_error(FDT_ERR_BADSTATE), + fdt_error(FDT_ERR_BADOFFSET), fdt_error(FDT_ERR_BADPATH), fdt_error(FDT_ERR_BADPHANDLE), + fdt_error(FDT_ERR_BADSTATE), - fdt_error(FDT_ERR_TRUNCATED), - fdt_error(FDT_ERR_BADMAGIC), - fdt_error(FDT_ERR_BADVERSION), - fdt_error(FDT_ERR_BADSTRUCTURE), - fdt_error(FDT_ERR_BADLAYOUT), - fdt_error(FDT_ERR_INTERNAL), - fdt_error(FDT_ERR_BADNCELLS), - fdt_error(FDT_ERR_BADVALUE), - fdt_error(FDT_ERR_BADOVERLAY), - fdt_error(FDT_ERR_NOPHANDLES), - fdt_error(FDT_ERR_BADFLAGS), - fdt_error(FDT_ERR_ALIGNMENT), + fdt_error(FDT_ERR_TRUNCATED), fdt_error(FDT_ERR_BADMAGIC), fdt_error(FDT_ERR_BADVERSION), + fdt_error(FDT_ERR_BADSTRUCTURE), fdt_error(FDT_ERR_BADLAYOUT), fdt_error(FDT_ERR_INTERNAL), + fdt_error(FDT_ERR_BADNCELLS), fdt_error(FDT_ERR_BADVALUE), fdt_error(FDT_ERR_BADOVERLAY), + fdt_error(FDT_ERR_NOPHANDLES), fdt_error(FDT_ERR_BADFLAGS), fdt_error(FDT_ERR_ALIGNMENT), }; #define fdt_error_length() mpux_array_size(cb_fdtErrTbl) @@ -51,25 +38,18 @@ static struct fdt_err cb_fdtErrTbl[] = { /// @brief Returns the error value as a string. /// @param errval /// @return -const char* fdt_strerror(int32_t errval) -{ - if (errval > 0) - { - return ("<valid offset/length>"); - } - else if (errval == 0) - { - return ("<no error>"); - } - else if (-errval < fdt_error_length()) - { - const char* serr = cb_fdtErrTbl[errval].e_str; - - if (serr != null) - { - return serr; - } - } - - return ("<unknown error>"); +const char* fdt_strerror(int32_t errval) { + if (errval > 0) { + return ("<valid offset/length>"); + } else if (errval == 0) { + return ("<no error>"); + } else if (-errval < fdt_error_length()) { + const char* serr = cb_fdtErrTbl[errval].e_str; + + if (serr != null) { + return serr; + } + } + + return ("<unknown error>"); } diff --git a/src/arm64/arm64-30pin.c b/src/arm64/arm64-30pin.c index f347f0d..eb89c67 100644 --- a/src/arm64/arm64-30pin.c +++ b/src/arm64/arm64-30pin.c @@ -1,10 +1,10 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ -#include <lib/partition-map.h> #include <lib/30pin.h> +#include <lib/partition-map.h> extern size_t cb_read_30pin(voidptr_t blob, size_t* size, size_t* start_lba); diff --git a/src/arm64/arm64-err.c b/src/arm64/arm64-err.c index 052b302..c734ada 100644 --- a/src/arm64/arm64-err.c +++ b/src/arm64/arm64-err.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,14 +10,12 @@ /// @brief Goes into a panic state. /// @param reason why? -void cb_panic(const char* reason) -{ - cb_put_string("panic: "); - cb_put_string(reason); - cb_put_char('\n'); +void cb_panic(const char* reason) { + cb_put_string("panic: "); + cb_put_string(reason); + cb_put_char('\n'); - while (yes) - { - asm volatile("hlt #0"); - } + while (yes) { + asm volatile("hlt #0"); + } } diff --git a/src/arm64/arm64-uart.c b/src/arm64/arm64-uart.c index 7455626..d587346 100644 --- a/src/arm64/arm64-uart.c +++ b/src/arm64/arm64-uart.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -9,47 +9,40 @@ /// BUGS: 0 -#define ARM64_MMIO_REG(addr) (*(volatile uint32_t*)(cb_uart_ptr + addr)) +#define ARM64_MMIO_REG(addr) (*(volatile uint32_t*) (cb_uart_ptr + addr)) /* this file handles the UART */ -static uint32_t* cb_uart_ptr = (uint32_t*)CB_UART_BASE; +static uint32_t* cb_uart_ptr = (uint32_t*) CB_UART_BASE; // we need that one, to avoid sending mutliple chars to UART. static boolean cb_locked_put_char = no; /// @brief Retrieve character from cb_uart_ptr -utf_char_t cb_get_char(void) -{ - while ((ARM64_MMIO_REG(0x018) & (1 << 4))) - { - } +utf_char_t cb_get_char(void) { + while ((ARM64_MMIO_REG(0x018) & (1 << 4))) { + } - return (utf_char_t)ARM64_MMIO_REG(0x0) & 0xFF; + return (utf_char_t) ARM64_MMIO_REG(0x0) & 0xFF; } -void cb_put_char(utf_char_t ch) -{ - while ((ARM64_MMIO_REG(0x018) & (1 << 5))) - { - } +void cb_put_char(utf_char_t ch) { + while ((ARM64_MMIO_REG(0x018) & (1 << 5))) { + } - ARM64_MMIO_REG(0x0) = ch; + ARM64_MMIO_REG(0x0) = ch; } /// @brief UART put string /// @param text the input text. -size_t cb_put_string(const char* text) -{ - if (text == nil) - return 0; +size_t cb_put_string(const char* text) { + if (text == nil) return 0; - size_t i = 0; + size_t i = 0; - for (; i < strlen(text); i++) - { - cb_put_char(text[i]); - } + for (; i < strlen(text); i++) { + cb_put_char(text[i]); + } - return i; + return i; } diff --git a/src/coreboot-bootnet.c b/src/coreboot-bootnet.c index 687edd9..a547b35 100644 --- a/src/coreboot-bootnet.c +++ b/src/coreboot-bootnet.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ diff --git a/src/coreboot-cpu-api.c b/src/coreboot-cpu-api.c index c118192..2491f15 100644 --- a/src/coreboot-cpu-api.c +++ b/src/coreboot-cpu-api.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,15 +8,13 @@ /// @brief Restarts the computer. /// @param none. -void cb_restart_machine(void) -{ +void cb_restart_machine(void) { #ifdef __COMPILE_RISCV__ - volatile uint32_t* brd_pwr = (volatile uint32_t*)0x100000; - *brd_pwr = 0x7777; // send reboot signal from DMA. + volatile uint32_t* brd_pwr = (volatile uint32_t*) 0x100000; + *brd_pwr = 0x7777; // send reboot signal from DMA. - while (1) - { - asm volatile("wfi"); - } + while (1) { + asm volatile("wfi"); + } #endif } diff --git a/src/coreboot-cxx-abi.cc b/src/coreboot-cxx-abi.cc index 858ba5e..70d9e62 100644 --- a/src/coreboot-cxx-abi.cc +++ b/src/coreboot-cxx-abi.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -9,83 +9,69 @@ /// BUGS: 0 extern "C" __SIZE_TYPE__ cb_put_string(const char* text); -extern "C" void cb_panic(const char* reason); +extern "C" void cb_panic(const char* reason); -extern "C" void __stack_chk_fail() -{ - cb_put_string("[stack-canary] Buffer overflow detected, halting...\n"); - cb_panic("stack_canary_fail"); +extern "C" void __stack_chk_fail() { + cb_put_string("[stack-canary] Buffer overflow detected, halting...\n"); + cb_panic("stack_canary_fail"); } void* __dso_handle; extern "C" __SIZE_TYPE__ cb_put_string(const char* text); -extern "C" void cb_panic(const char* reason); +extern "C" void cb_panic(const char* reason); atexit_func_entry_t __atexit_funcs[DSO_MAX_OBJECTS]; -uarch_t __atexit_func_count; +uarch_t __atexit_func_count; -extern "C" void __cxa_pure_virtual() -{ - cb_put_string("[__cxa_pure_virtual] Placeholder\n"); +extern "C" void __cxa_pure_virtual() { + cb_put_string("[__cxa_pure_virtual] Placeholder\n"); } -extern "C" int __cxa_atexit(void (*f)(void*), void* arg, void* dso) -{ - if (__atexit_func_count >= DSO_MAX_OBJECTS) - return -1; +extern "C" int __cxa_atexit(void (*f)(void*), void* arg, void* dso) { + if (__atexit_func_count >= DSO_MAX_OBJECTS) return -1; - __atexit_funcs[__atexit_func_count].destructor_func = f; - __atexit_funcs[__atexit_func_count].obj_ptr = arg; - __atexit_funcs[__atexit_func_count].dso_handle = dso; + __atexit_funcs[__atexit_func_count].destructor_func = f; + __atexit_funcs[__atexit_func_count].obj_ptr = arg; + __atexit_funcs[__atexit_func_count].dso_handle = dso; - __atexit_func_count++; + __atexit_func_count++; - return 0; + return 0; } -extern "C" void __cxa_finalize(void* f) -{ - uarch_t i = __atexit_func_count; - if (!f) - { - while (i--) - { - if (__atexit_funcs[i].destructor_func) - { - (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); - }; - } - - return; - } - - while (i--) - { - if (__atexit_funcs[i].destructor_func) - { - (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); - __atexit_funcs[i].destructor_func = 0; - }; - } +extern "C" void __cxa_finalize(void* f) { + uarch_t i = __atexit_func_count; + if (!f) { + while (i--) { + if (__atexit_funcs[i].destructor_func) { + (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); + }; + } + + return; + } + + while (i--) { + if (__atexit_funcs[i].destructor_func) { + (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); + __atexit_funcs[i].destructor_func = 0; + }; + } } -namespace cxxabiv1 -{ - extern "C" int __cxa_guard_acquire(__guard* g) - { - (void)g; - return 0; - } - - extern "C" int __cxa_guard_release(__guard* g) - { - *(char*)g = 1; - return 0; - } - - extern "C" void __cxa_guard_abort(__guard* g) - { - (void)g; - } -} // namespace cxxabiv1 +namespace cxxabiv1 { +extern "C" int __cxa_guard_acquire(__guard* g) { + (void) g; + return 0; +} + +extern "C" int __cxa_guard_release(__guard* g) { + *(char*) g = 1; + return 0; +} + +extern "C" void __cxa_guard_abort(__guard* g) { + (void) g; +} +} // namespace cxxabiv1 diff --git a/src/coreboot-partition-map-parse.c b/src/coreboot-partition-map-parse.c index 85ccf1b..7d8f80f 100644 --- a/src/coreboot-partition-map-parse.c +++ b/src/coreboot-partition-map-parse.c @@ -1,60 +1,42 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ #include <lib/partition-map.h> -bool cb_parse_partition_block_data_at(voidptr_t blob, size_t blob_sz, size_t index, size_t* end_lba, size_t* start_lba, size_t* sector_sz) -{ - if (!start_lba || - !end_lba || - !blob || - !blob_sz || - !sector_sz || - (sizeof(part_block_t) * index) > blob_sz) - return false; - - part_block_t* block = (part_block_t*)(blob + (sizeof(part_block_t) * index)); - - if (block->version != EPM_REVISION || - block->num_blocks < 1 || - block->num_blocks > EPM_MAX_BLKS || - strcmp(block->magic, EPM_MAGIC) > 0 || - block->lba_end == 0 || - block->lba_start == 0) - { - return false; - } - - *end_lba = block->lba_end; - *start_lba = block->lba_start; - *sector_sz = block->sector_sz; - - return true; +bool cb_parse_partition_block_data_at(voidptr_t blob, size_t blob_sz, size_t index, size_t* end_lba, + size_t* start_lba, size_t* sector_sz) { + if (!start_lba || !end_lba || !blob || !blob_sz || !sector_sz || + (sizeof(part_block_t) * index) > blob_sz) + return false; + + part_block_t* block = (part_block_t*) (blob + (sizeof(part_block_t) * index)); + + if (block->version != EPM_REVISION || block->num_blocks < 1 || block->num_blocks > EPM_MAX_BLKS || + strcmp(block->magic, EPM_MAGIC) > 0 || block->lba_end == 0 || block->lba_start == 0) { + return false; + } + + *end_lba = block->lba_end; + *start_lba = block->lba_start; + *sector_sz = block->sector_sz; + + return true; } -part_block_t* cb_parse_partition_block_at(voidptr_t blob, size_t blob_sz, size_t index) -{ - if (!blob || - !blob_sz || - (sizeof(part_block_t) * index) > blob_sz) - return nil; +part_block_t* cb_parse_partition_block_at(voidptr_t blob, size_t blob_sz, size_t index) { + if (!blob || !blob_sz || (sizeof(part_block_t) * index) > blob_sz) return nil; - part_block_t* block = (part_block_t*)(blob + (sizeof(part_block_t) * index)); + part_block_t* block = (part_block_t*) (blob + (sizeof(part_block_t) * index)); - cb_put_string(block->magic); + cb_put_string(block->magic); - if (block->version != EPM_REVISION || - block->num_blocks < 1 || - block->num_blocks > EPM_MAX_BLKS || - strcmp(block->magic, EPM_MAGIC) > 0 || - block->lba_end == 0 || - block->lba_start == 0) - { - return nil; - } + if (block->version != EPM_REVISION || block->num_blocks < 1 || block->num_blocks > EPM_MAX_BLKS || + strcmp(block->magic, EPM_MAGIC) > 0 || block->lba_end == 0 || block->lba_start == 0) { + return nil; + } - return block; + return block; }
\ No newline at end of file diff --git a/src/coreboot-partition-map.c b/src/coreboot-partition-map.c index 69bcddd..f5d937b 100644 --- a/src/coreboot-partition-map.c +++ b/src/coreboot-partition-map.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,28 +10,21 @@ // include this for documentation. #define CB_FILESYSTEM_COUNT 4 -#define CB_FILESYSTEM_LIST \ - { \ - "NeFS", "HeFS", "FAT32", "ext4" \ - } +#define CB_FILESYSTEM_LIST \ + { "NeFS", "HeFS", "FAT32", "ext4" } /// @brief check if filesystem is supported by CoreBoot. /// @param fs the filesystem magic, as provided by EPM. -boolean cb_filesystem_exists(caddr_t fs, size_t len) -{ - if (fs == nil || - *fs == 0) - return no; - - char* fs_list[] = CB_FILESYSTEM_LIST; - - for (size_t fs_index = 0; fs_index < CB_FILESYSTEM_COUNT; fs_index++) - { - if (strncmp(fs_list[fs_index], fs, strlen(fs_list[fs_index])) == 0) - { - return yes; - } - } - - return no; +boolean cb_filesystem_exists(caddr_t fs, size_t len) { + if (fs == nil || *fs == 0) return no; + + char* fs_list[] = CB_FILESYSTEM_LIST; + + for (size_t fs_index = 0; fs_index < CB_FILESYSTEM_COUNT; fs_index++) { + if (strncmp(fs_list[fs_index], fs, strlen(fs_list[fs_index])) == 0) { + return yes; + } + } + + return no; } diff --git a/src/coreboot-pci-tree.c b/src/coreboot-pci-tree.c index b39c024..ce168fd 100644 --- a/src/coreboot-pci-tree.c +++ b/src/coreboot-pci-tree.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -23,84 +23,74 @@ /// Standard Root table (Mahrouss Table) #define CB_PCI_ROOT_NAME "/pci-tree/@/" -static struct hw_cb_pci_tree* cb_base_tree = nil; +static struct hw_cb_pci_tree* cb_base_tree = nil; static struct hw_cb_pci_tree* cb_latest_tree = nil; -static struct hw_cb_pci_tree* cb_last_tree = nil; +static struct hw_cb_pci_tree* cb_last_tree = nil; /// \brief Init the PCI device tree structure. /// \return if it already exists -> false /// Otherwise true. -boolean cb_pci_init_tree(void) -{ - cb_base_tree = (struct hw_cb_pci_tree*)(CB_PCI_TREE_BASE); +boolean cb_pci_init_tree(void) { + cb_base_tree = (struct hw_cb_pci_tree*) (CB_PCI_TREE_BASE); - // huh? anyway let's ignore it then. - if (cb_base_tree->d_magic != CB_PCI_DEV_MAGIC) - { - cb_base_tree->d_magic = CB_PCI_DEV_MAGIC; + // huh? anyway let's ignore it then. + if (cb_base_tree->d_magic != CB_PCI_DEV_MAGIC) { + cb_base_tree->d_magic = CB_PCI_DEV_MAGIC; - memncpy(cb_base_tree->d_name, CB_PCI_ROOT_NAME, strlen(CB_PCI_ROOT_NAME)); + memncpy(cb_base_tree->d_name, CB_PCI_ROOT_NAME, strlen(CB_PCI_ROOT_NAME)); - cb_base_tree->d_next_sibling = 0; - cb_base_tree->d_off_props = 0; - cb_base_tree->d_sz_struct = 0; - cb_base_tree->d_sz_props = 0; - cb_base_tree->d_off_struct = 0; - cb_base_tree->d_version = CB_PCI_VERSION; + cb_base_tree->d_next_sibling = 0; + cb_base_tree->d_off_props = 0; + cb_base_tree->d_sz_struct = 0; + cb_base_tree->d_sz_props = 0; + cb_base_tree->d_off_struct = 0; + cb_base_tree->d_version = CB_PCI_VERSION; - cb_base_tree->d_next_sibling = - (cb_pci_num_t)(cb_base_tree + sizeof(struct hw_cb_pci_tree)); - cb_base_tree->d_first_node = (cb_pci_num_t)cb_base_tree; + cb_base_tree->d_next_sibling = (cb_pci_num_t) (cb_base_tree + sizeof(struct hw_cb_pci_tree)); + cb_base_tree->d_first_node = (cb_pci_num_t) cb_base_tree; - cb_put_string(">> Append root device: " CB_PCI_ROOT_NAME "\r\n"); - } + cb_put_string(">> Append root device: " CB_PCI_ROOT_NAME "\r\n"); + } - cb_latest_tree = cb_base_tree; + cb_latest_tree = cb_base_tree; - return yes; + return yes; } /// \brief Adds a new device to the tree. /// \param name the device name. /// \param struct_ptr the struct containing the device. /// \param struct_sz the structure size. -boolean cb_pci_append_tree(const caddr_t name, cb_pci_num_t struct_ptr, cb_pci_num_t struct_sz) -{ - if (!name || *name == 0 || cb_latest_tree == nil) - return no; +boolean cb_pci_append_tree(const caddr_t name, cb_pci_num_t struct_ptr, cb_pci_num_t struct_sz) { + if (!name || *name == 0 || cb_latest_tree == nil) return no; - struct hw_cb_pci_tree* cb_pci_tree = (struct hw_cb_pci_tree*)(cb_latest_tree); + struct hw_cb_pci_tree* cb_pci_tree = (struct hw_cb_pci_tree*) (cb_latest_tree); - while (cb_pci_tree->d_magic == CB_PCI_DEV_MAGIC) - { - if (strcmp(cb_pci_tree->d_name, name) == 0) - return no; + while (cb_pci_tree->d_magic == CB_PCI_DEV_MAGIC) { + if (strcmp(cb_pci_tree->d_name, name) == 0) return no; - cb_pci_tree = - (struct hw_cb_pci_tree*)(cb_pci_tree + - sizeof(struct hw_cb_pci_tree)); - } + cb_pci_tree = (struct hw_cb_pci_tree*) (cb_pci_tree + sizeof(struct hw_cb_pci_tree)); + } - cb_pci_tree->d_magic = CB_PCI_DEV_MAGIC; + cb_pci_tree->d_magic = CB_PCI_DEV_MAGIC; - memncpy(cb_pci_tree->d_name, name, strlen(name)); + memncpy(cb_pci_tree->d_name, name, strlen(name)); - cb_pci_tree->d_off_struct = struct_ptr; - cb_pci_tree->d_sz_struct = struct_sz; - cb_pci_tree->d_off_props = 0; - cb_pci_tree->d_sz_props = 0; - cb_pci_tree->d_version = CB_PCI_VERSION; + cb_pci_tree->d_off_struct = struct_ptr; + cb_pci_tree->d_sz_struct = struct_sz; + cb_pci_tree->d_off_props = 0; + cb_pci_tree->d_sz_props = 0; + cb_pci_tree->d_version = CB_PCI_VERSION; - cb_pci_tree->d_next_sibling = - (cb_pci_num_t)(cb_pci_tree + sizeof(struct hw_cb_pci_tree)); - cb_pci_tree->d_first_node = (cb_pci_num_t)cb_latest_tree; + cb_pci_tree->d_next_sibling = (cb_pci_num_t) (cb_pci_tree + sizeof(struct hw_cb_pci_tree)); + cb_pci_tree->d_first_node = (cb_pci_num_t) cb_latest_tree; - cb_latest_tree = cb_pci_tree; - cb_last_tree = cb_pci_tree; + cb_latest_tree = cb_pci_tree; + cb_last_tree = cb_pci_tree; - cb_put_string(">> Append device: "); - cb_put_string(name); - cb_put_string("\r\n"); + cb_put_string(">> Append device: "); + cb_put_string(name); + cb_put_string("\r\n"); - return yes; + return yes; } diff --git a/src/coreboot-print-name.c b/src/coreboot-print-name.c index e2ad8c4..6adb099 100644 --- a/src/coreboot-print-name.c +++ b/src/coreboot-print-name.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,21 +8,20 @@ /// @brief Print firmware name. /// @param -void cb_print_name(void) -{ +void cb_print_name(void) { #ifdef __COMPILE_POWERPC__ - cb_put_string(">> CoreBoot for POWERPC.\r\n"); -#endif // __COMPILE_POWERPC__ + cb_put_string(">> CoreBoot for POWERPC.\r\n"); +#endif // __COMPILE_POWERPC__ #ifdef __COMPILE_ARM64__ - cb_put_string(">> CoreBoot for ARM64.\r\n"); -#endif // __COMPILE_POWERPC__ + cb_put_string(">> CoreBoot for ARM64.\r\n"); +#endif // __COMPILE_POWERPC__ #ifdef __COMPILE_AMD64__ - cb_put_string(">> CoreBoot for AMD64.\r\n"); -#endif // __COMPILE_POWERPC__ + cb_put_string(">> CoreBoot for AMD64.\r\n"); +#endif // __COMPILE_POWERPC__ #ifdef __COMPILE_RISCV__ - cb_put_string(">> CoreBoot for RISC-V.\r\n"); -#endif // __COMPILE_POWERPC__ + cb_put_string(">> CoreBoot for RISC-V.\r\n"); +#endif // __COMPILE_POWERPC__ } diff --git a/src/coreboot-start.c b/src/coreboot-start.c index cfcc668..da6da23 100644 --- a/src/coreboot-start.c +++ b/src/coreboot-start.c @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ +#include <lib/boot.h> #include <lib/mp-bit.h> #include <lib/partition-map.h> #include <lib/pci-tree.h> -#include <lib/boot.h> /// BUGS: 0 @@ -34,135 +34,117 @@ uint64_t __cb_hart_counter = 0UL; /// @brief Start executing the firmware. /// @param -void cb_start_exec(void) -{ +void cb_start_exec(void) { #ifndef __COMPILE_RISCV__ - static uint64_t __cb_hart_counter = 0UL; + static uint64_t __cb_hart_counter = 0UL; #endif - ++__cb_hart_counter; + ++__cb_hart_counter; - uintptr_t hart = __cb_hart_counter; + uintptr_t hart = __cb_hart_counter; - // let the hart 0 init our stuff. - if (hart == 0) - { - cb_put_string("CB> Welcome to CoreBoot, (c) Amlal EL Mahrouss. Built the "); - cb_put_string(__DATE__); - cb_put_string("\r\r\n"); + // let the hart 0 init our stuff. + if (hart == 0) { + cb_put_string("CB> Welcome to CoreBoot, (c) Amlal EL Mahrouss. Built the "); + cb_put_string(__DATE__); + cb_put_string("\r\r\n"); #ifdef __COMPILE_POWERPC__ - cb_put_string("CB> CPU: PowerPC 64-bit Based SoC.\r\r\n"); -#endif // __COMPILE_POWERPC__ + cb_put_string("CB> CPU: PowerPC 64-bit Based SoC.\r\r\n"); +#endif // __COMPILE_POWERPC__ #ifdef __COMPILE_AMD64__ - cb_put_string("CB> CPU: x64 Based SoC.\r\r\n"); -#endif // __COMPILE_AMD64__ + cb_put_string("CB> CPU: x64 Based SoC.\r\r\n"); +#endif // __COMPILE_AMD64__ #ifdef __COMPILE_ARM64__ - cb_put_string("CB> CPU: AArch64 Based SoC.\r\r\n"); -#endif // __COMPILE_ARM64__ + cb_put_string("CB> CPU: AArch64 Based SoC.\r\r\n"); +#endif // __COMPILE_ARM64__ #ifdef __COMPILE_ARM32__ - cb_put_string("CB> CPU: AArch32 Based SoC.\r\r\n"); -#endif // __COMPILE_ARM64__ + cb_put_string("CB> CPU: AArch32 Based SoC.\r\r\n"); +#endif // __COMPILE_ARM64__ #ifdef __COMPILE_RISCV__ - cb_put_string("CB> CPU: RV64 Based SoC.\r\r\n"); -#endif // __COMPILE_RISCV__ - } + cb_put_string("CB> CPU: RV64 Based SoC.\r\r\n"); +#endif // __COMPILE_RISCV__ + } - /// @brief Boots here if LX header matches what we except. + /// @brief Boots here if LX header matches what we except. - volatile struct cb_boot_header* boot_hdr = - (volatile struct cb_boot_header*)(CB_FLASH_BASE_ADDR); + volatile struct cb_boot_header* boot_hdr = (volatile struct cb_boot_header*) (CB_FLASH_BASE_ADDR); - /** - boot if: - - ident matches. - - version matches. + /** + boot if: + - ident matches. + - version matches. */ - if (boot_hdr->h_mag[0] == CB_BOOT_MAG_0 && - boot_hdr->h_mag[1] == CB_BOOT_MAG_1) - { - if (boot_hdr->h_revision != CB_BOOT_VER) - { - if (hart == 0) - { - cb_put_string("CB> Can't Boot the StageTwo, LX invalid signature. (CB0003)\r\n"); - } - } - else - { - if (hart == 0) - { - cb_pci_append_tree("@stage2-lx", (cb_pci_num_t)boot_hdr, sizeof(struct cb_boot_header)); - - cb_put_string("CB> Executing StageTwo: "); - cb_put_string((const char*)boot_hdr->h_name); - cb_put_char('\r'); - cb_put_char('\n'); - - // printf("CB> address: %x\n", boot_hdr->h_start_address); - } - - if (boot_hdr->h_start_address != 0) - { - cb_boot_processor_ready = 1; - cb_start_context(boot_hdr->h_start_address); - } - - cb_put_string("CB> StageTwo has returned? (CB0002)\r\n"); - } - } - else - { - cb_put_string("CB> Trying EPM partition...\r\n"); - - part_block_t* blk = cb_parse_partition_block_at((voidptr_t)CB_FLASH_BASE_ADDR, EPM_PART_BLK_SZ, 0); - - if (blk) - { - cb_pci_append_tree("@stage2-epm", (cb_pci_num_t)blk, sizeof(part_block_t) * blk->num_blocks); - - size_t indx = 0; - size_t end_lba, start_lba, sector_sz; - - while (indx < blk->num_blocks) - { - if (cb_parse_partition_block_data_at(blk, EPM_PART_BLK_SZ * blk->num_blocks, indx, &end_lba, &start_lba, §or_sz) == no) - { - ++indx; - continue; - } - - cb_boot_processor_ready = 1; - cb_start_context((uintptr_t)(voidptr_t)blk + start_lba); - - if (hart == 1) - { - cb_put_string("CB> Can't boot to StageTwo. (CB0001)\r\n"); - } - } - } - - if (hart == 1) - { - cb_put_string("CB> Can't boot to StageTwo via EPM, no bootable partition blocks found. (CB0001)\r\n"); - } - } - - /// end of TODO - - if (hart > 1) - { - while (yes) - { - if (__cb_hart_counter == 0) - { - cb_restart_machine(); - } - } - } + if (boot_hdr->h_mag[0] == CB_BOOT_MAG_0 && boot_hdr->h_mag[1] == CB_BOOT_MAG_1) { + if (boot_hdr->h_revision != CB_BOOT_VER) { + if (hart == 0) { + cb_put_string("CB> Can't Boot the StageTwo, LX invalid signature. (CB0003)\r\n"); + } + } else { + if (hart == 0) { + cb_pci_append_tree("@stage2-lx", (cb_pci_num_t) boot_hdr, sizeof(struct cb_boot_header)); + + cb_put_string("CB> Executing StageTwo: "); + cb_put_string((const char*) boot_hdr->h_name); + cb_put_char('\r'); + cb_put_char('\n'); + + // printf("CB> address: %x\n", boot_hdr->h_start_address); + } + + if (boot_hdr->h_start_address != 0) { + cb_boot_processor_ready = 1; + cb_start_context(boot_hdr->h_start_address); + } + + cb_put_string("CB> StageTwo has returned? (CB0002)\r\n"); + } + } else { + cb_put_string("CB> Trying EPM partition...\r\n"); + + part_block_t* blk = + cb_parse_partition_block_at((voidptr_t) CB_FLASH_BASE_ADDR, EPM_PART_BLK_SZ, 0); + + if (blk) { + cb_pci_append_tree("@stage2-epm", (cb_pci_num_t) blk, sizeof(part_block_t) * blk->num_blocks); + + size_t indx = 0; + size_t end_lba, start_lba, sector_sz; + + while (indx < blk->num_blocks) { + if (cb_parse_partition_block_data_at(blk, EPM_PART_BLK_SZ * blk->num_blocks, indx, &end_lba, + &start_lba, §or_sz) == no) { + ++indx; + continue; + } + + cb_boot_processor_ready = 1; + cb_start_context((uintptr_t) (voidptr_t) blk + start_lba); + + if (hart == 1) { + cb_put_string("CB> Can't boot to StageTwo. (CB0001)\r\n"); + } + } + } + + if (hart == 1) { + cb_put_string( + "CB> Can't boot to StageTwo via EPM, no bootable partition blocks found. (CB0001)\r\n"); + } + } + + /// end of TODO + + if (hart > 1) { + while (yes) { + if (__cb_hart_counter == 0) { + cb_restart_machine(); + } + } + } } diff --git a/src/coreboot-string.c b/src/coreboot-string.c index 491095d..355e734 100644 --- a/src/coreboot-string.c +++ b/src/coreboot-string.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -19,167 +19,135 @@ /// BUGS: 0 -size_t strncmp(const char* src, const char* cmp, size_t size) -{ - if (src == nil) - return 0; +size_t strncmp(const char* src, const char* cmp, size_t size) { + if (src == nil) return 0; - int32_t counter = 0; + int32_t counter = 0; - for (size_t index = 0; index < size; ++index) - { - if (src[index] != cmp[index]) - ++counter; - } + for (size_t index = 0; index < size; ++index) { + if (src[index] != cmp[index]) ++counter; + } - return counter; + return counter; } -void* memset(void* ptr, const char value, size_t len) -{ - if (ptr == nil) - return nil; +void* memset(void* ptr, const char value, size_t len) { + if (ptr == nil) return nil; - char* start = ptr; + char* start = ptr; - while (len) - { - *start = value; - ++start; + while (len) { + *start = value; + ++start; - --len; - } + --len; + } - return (void*)start; + return (void*) start; } -void* memmove(void* dest, const void* src, size_t len) -{ - memncpy(dest, src, len); - return dest; +void* memmove(void* dest, const void* src, size_t len) { + memncpy(dest, src, len); + return dest; } -size_t memcpy(void* dst, const void* src) -{ - if (src == nil || dst == nil) - return 0; +size_t memcpy(void* dst, const void* src) { + if (src == nil || dst == nil) return 0; - const char* src_chr = src; - char* dst_chr = dst; - size_t index = 0; - size_t len = strlen(src); + const char* src_chr = src; + char* dst_chr = dst; + size_t index = 0; + size_t len = strlen(src); - while (index < len) - { - dst_chr[index] = src_chr[index]; - ++index; - } + while (index < len) { + dst_chr[index] = src_chr[index]; + ++index; + } - return 0; + return 0; } /* @brief unoptimized memcpy, TODO: use isa specific memcpy. */ -size_t memncpy(void* dst, const void* src, size_t len) -{ +size_t memncpy(void* dst, const void* src, size_t len) { #if __OL == 3 && defined(__riscv) - riscv_memncpy(dst, src, len); + riscv_memncpy(dst, src, len); #else - if (src == nil || dst == nil) - return 0; + if (src == nil || dst == nil) return 0; - const char* src_chr = src; - char* dst_chr = dst; - size_t index = 0; + const char* src_chr = src; + char* dst_chr = dst; + size_t index = 0; - while (index < len) - { - dst_chr[index] = src_chr[index]; - ++index; - } + while (index < len) { + dst_chr[index] = src_chr[index]; + ++index; + } - return 0; + return 0; #endif } -size_t strlen(const char* str) -{ - if (*str == 0) - return 0; +size_t strlen(const char* str) { + if (*str == 0) return 0; - size_t len = 0; - while (str[len] != '\0') - ++len; + size_t len = 0; + while (str[len] != '\0') ++len; - return len; + return len; } -size_t strnlen(const char* str, size_t len) -{ - size_t cnt = 0; +size_t strnlen(const char* str, size_t len) { + size_t cnt = 0; - while (len > cnt) - { - ++cnt; + while (len > cnt) { + ++cnt; - if (str[cnt] == '\0') - return (size_t)-1; - } + if (str[cnt] == '\0') return (size_t) -1; + } - return len; + return len; } -void strreverse(char* s) -{ - if (s == nil) - return; - if (*s == '\0') - return; +void strreverse(char* s) { + if (s == nil) return; + if (*s == '\0') return; - char *first, *last, temp; + char *first, *last, temp; - first = s; - last = s + strlen(s) - 1; + first = s; + last = s + strlen(s) - 1; - while (first != last) - { - temp = *first; - *(first++) = *last; - *(last--) = temp; - } + while (first != last) { + temp = *first; + *(first++) = *last; + *(last--) = temp; + } } -char* strchr(char* str, const char chr) -{ - while (*str != chr) - { - ++str; +char* strchr(char* str, const char chr) { + while (*str != chr) { + ++str; - if (*str == 0) - return nil; - } + if (*str == 0) return nil; + } - return str; + return str; } /// @brief Compare two strings. /// @param src source string /// @param cmp string to compare. /// @return -size_t strcmp(caddr_t src, caddr_t cmp) -{ - if (src == null || *src == 0) - return 1; - if (cmp == null || *cmp == 0) - return 1; - - int32_t counter = 0; - - for (size_t index = 0; src[index] != 0; ++index) - { - if (cmp[index] != src[index]) - ++counter; - } - - return counter; +size_t strcmp(caddr_t src, caddr_t cmp) { + if (src == null || *src == 0) return 1; + if (cmp == null || *cmp == 0) return 1; + + int32_t counter = 0; + + for (size_t index = 0; src[index] != 0; ++index) { + if (cmp[index] != src[index]) ++counter; + } + + return counter; } diff --git a/src/hal/coreboot-ahci-driver.c b/src/hal/coreboot-ahci-driver.c index 2ef2098..26a8907 100644 --- a/src/hal/coreboot-ahci-driver.c +++ b/src/hal/coreboot-ahci-driver.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -15,8 +15,8 @@ * */ -#include <lib/pci-tree.h> #include <lib/boot.h> +#include <lib/pci-tree.h> #define CB_AHCI_DRIVER_NAME ("@sata") @@ -24,85 +24,73 @@ /// @brief AHCI support for PowerPC. /// @brief AHCI HBA port. -typedef struct cb_hba_port -{ - uint32_t clb; // 0x00, command list base address, 1K-byte aligned - uint32_t clbu; // 0x04, command list base address upper 32 bits - uint32_t fb; // 0x08, FIS base address, 256-byte aligned - uint32_t fbu; // 0x0C, FIS base address upper 32 bits - uint32_t is; // 0x10, interrupt status - uint32_t ie; // 0x14, interrupt enable - uint32_t cmd; // 0x18, command and status - uint32_t reserved0; // 0x1C, Reserved - uint32_t tfd; // 0x20, task file data - uint32_t sig; // 0x24, signature - uint32_t ssts; // 0x28, SATA status (SCR0:SStatus) - uint32_t sctl; // 0x2C, SATA control (SCR2:SControl) - uint32_t serr; // 0x30, SATA error (SCR1:SError) - uint32_t sact; // 0x34, SATA active (SCR3:SActive) - uint32_t ci; // 0x38, command issue - uint32_t sntf; // 0x20, SATA notification (SCR4:SNotification) - uint32_t fbs; // 0x40, FIS-based switch control - uint32_t reserved1[11]; // 0x44 ~ 0x6F, Reserved - uint32_t vendor[4]; // 0x70 ~ 0x7F, vendor specific +typedef struct cb_hba_port { + uint32_t clb; // 0x00, command list base address, 1K-byte aligned + uint32_t clbu; // 0x04, command list base address upper 32 bits + uint32_t fb; // 0x08, FIS base address, 256-byte aligned + uint32_t fbu; // 0x0C, FIS base address upper 32 bits + uint32_t is; // 0x10, interrupt status + uint32_t ie; // 0x14, interrupt enable + uint32_t cmd; // 0x18, command and status + uint32_t reserved0; // 0x1C, Reserved + uint32_t tfd; // 0x20, task file data + uint32_t sig; // 0x24, signature + uint32_t ssts; // 0x28, SATA status (SCR0:SStatus) + uint32_t sctl; // 0x2C, SATA control (SCR2:SControl) + uint32_t serr; // 0x30, SATA error (SCR1:SError) + uint32_t sact; // 0x34, SATA active (SCR3:SActive) + uint32_t ci; // 0x38, command issue + uint32_t sntf; // 0x20, SATA notification (SCR4:SNotification) + uint32_t fbs; // 0x40, FIS-based switch control + uint32_t reserved1[11]; // 0x44 ~ 0x6F, Reserved + uint32_t vendor[4]; // 0x70 ~ 0x7F, vendor specific } cb_hba_port_t; /// @brief Check if port is active. /// @param port host bus address port. /// @return whether sact is active or not. -static boolean cb_hba_port_active(volatile cb_hba_port_t* port) -{ - if (!port) - return false; +static boolean cb_hba_port_active(volatile cb_hba_port_t* port) { + if (!port) return false; - return port->sact; + return port->sact; } /// @brief Start HBA command processor. /// @param port host bus address port. /// @return whether it was successful or not. -static boolean cb_hba_start_cmd(volatile cb_hba_port_t* port) -{ - if (!port) - return false; +static boolean cb_hba_start_cmd(volatile cb_hba_port_t* port) { + if (!port) return false; - size_t timeout = 1000000; + size_t timeout = 1000000; - while ((port->cmd & 0x8000)) - { - if (!timeout) - return false; + while ((port->cmd & 0x8000)) { + if (!timeout) return false; - --timeout; - } + --timeout; + } - port->cmd |= 0x0001; - port->cmd |= 0x0010; + port->cmd |= 0x0001; + port->cmd |= 0x0010; - return true; + return true; } /// @brief Stop HBA command from processing. /// @param port host bus address port. /// @return whether it was successful or not. -static boolean cb_hba_stop_cmd(volatile cb_hba_port_t* port) -{ - if (!port) - return false; +static boolean cb_hba_stop_cmd(volatile cb_hba_port_t* port) { + if (!port) return false; - port->cmd &= ~0x0001; - port->cmd &= ~0x0010; + port->cmd &= ~0x0001; + port->cmd &= ~0x0010; - while (yes) - { - if ((port->cmd & 0x8000)) - continue; + while (yes) { + if ((port->cmd & 0x8000)) continue; - if ((port->cmd & 0x4000)) - continue; + if ((port->cmd & 0x4000)) continue; - break; - } + break; + } - return true; + return true; } diff --git a/src/hal/coreboot-flash.c b/src/hal/coreboot-flash.c index 1416bc3..d1b0907 100644 --- a/src/hal/coreboot-flash.c +++ b/src/hal/coreboot-flash.c @@ -4,7 +4,7 @@ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ +#include <lib/boot.h> #include <lib/mp-bit.h> #include <lib/partition-map.h> #include <lib/pci-tree.h> -#include <lib/boot.h> diff --git a/src/ppc64/ppc64-err.c b/src/ppc64/ppc64-err.c index 13d944c..1ef0089 100644 --- a/src/ppc64/ppc64-err.c +++ b/src/ppc64/ppc64-err.c @@ -1,6 +1,6 @@ /* -------------------------------------------
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
@@ -10,14 +10,12 @@ /// @brief Goes into a panic state.
/// @param reason why?
-void cb_panic(const char* reason)
-{
- cb_put_string("Error: ");
- cb_put_string(reason);
- cb_put_char('\n');
+void cb_panic(const char* reason) {
+ cb_put_string("Error: ");
+ cb_put_string(reason);
+ cb_put_char('\n');
- while (yes)
- {
- (void)0;
- }
+ while (yes) {
+ (void) 0;
+ }
}
diff --git a/src/ppc64/ppc64-hal.c b/src/ppc64/ppc64-hal.c index f47f0b3..74d18c4 100644 --- a/src/ppc64/ppc64-hal.c +++ b/src/ppc64/ppc64-hal.c @@ -1,100 +1,87 @@ /* -------------------------------------------
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
#include <lib/ppc64/mmu.h>
#include <lib/ppc64/processor.h>
-#include <lib/pci-tree.h>
#include <lib/boot.h>
+#include <lib/pci-tree.h>
-void cb_write_tlb(uint32_t mas0, uint32_t mas1, uint32_t mas2, uint32_t mas3, uint32_t mas7)
-{
- mtspr(MAS0, mas0);
- mtspr(MAS1, mas1);
- mtspr(MAS2, mas2);
- mtspr(MAS3, mas3);
- mtspr(MAS7, mas7);
+void cb_write_tlb(uint32_t mas0, uint32_t mas1, uint32_t mas2, uint32_t mas3, uint32_t mas7) {
+ mtspr(MAS0, mas0);
+ mtspr(MAS1, mas1);
+ mtspr(MAS2, mas2);
+ mtspr(MAS3, mas3);
+ mtspr(MAS7, mas7);
- cb_flush_tlb();
+ cb_flush_tlb();
}
-void cb_set_tlb(uint8_t tlb,
- uint32_t epn,
- uint64_t rpn,
- uint8_t perms,
- uint8_t wimge,
- uint8_t ts,
- uint8_t esel,
- uint8_t tsize,
- uint8_t iprot)
-{
- if ((mfspr(SPRN_MMUCFG) & MMUCFG_MAVN) == MMUCFG_MAVN_V1 && (tsize & 1))
- {
- // this mmu-version does not allow odd tsize values
- return;
- }
-
- uint32_t mas0 = FSL_BOOKE_MAS0(tlb, esel, 0);
- uint32_t mas1 = FSL_BOOKE_MAS1(1, iprot, 0, ts, tsize);
- uint32_t mas2 = FSL_BOOKE_MAS2(epn, wimge);
- uint32_t mas3 = FSL_BOOKE_MAS3(rpn, 0, perms);
- uint32_t mas7 = FSL_BOOKE_MAS7(rpn);
-
- cb_write_tlb(mas0, mas1, mas2, mas3, mas7);
+void cb_set_tlb(uint8_t tlb, uint32_t epn, uint64_t rpn, uint8_t perms, uint8_t wimge, uint8_t ts,
+ uint8_t esel, uint8_t tsize, uint8_t iprot) {
+ if ((mfspr(SPRN_MMUCFG) & MMUCFG_MAVN) == MMUCFG_MAVN_V1 && (tsize & 1)) {
+ // this mmu-version does not allow odd tsize values
+ return;
+ }
+
+ uint32_t mas0 = FSL_BOOKE_MAS0(tlb, esel, 0);
+ uint32_t mas1 = FSL_BOOKE_MAS1(1, iprot, 0, ts, tsize);
+ uint32_t mas2 = FSL_BOOKE_MAS2(epn, wimge);
+ uint32_t mas3 = FSL_BOOKE_MAS3(rpn, 0, perms);
+ uint32_t mas7 = FSL_BOOKE_MAS7(rpn);
+
+ cb_write_tlb(mas0, mas1, mas2, mas3, mas7);
}
/// @brief Init hardware before jumping to kernel.
/// @param
-void cb_init_hw(void)
-{
-
- /// amlal:
- /// map VGA framebuffer
- cb_set_tlb(0, CB_FRAMEBUFFER_ADDR, /* v_addr, 0x0000A0000 */
- 0x0000A000, /* p_addr. 0x0000A0000 */
- MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
- MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
- 0, /* ts i.e AS=0 */
- 1, /* esel (a.k.a tlb_index*/
- BOOKE_PAGESZ_64K, /* tsize ie 2^10kB ie 1MB */
- 1);
-
- // map ccsrbar and uart.
- // at start we execute from esel = 0, so chose something else..
- cb_set_tlb(1, CB_UART_BASE, /* v_addr 0xe0000000 see qemu-ppce500.h */
- 0xfe0000000, /* p_addr. 0xfe0000000 */
- MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
- MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
- 0, /* ts i.e AS=0 */
- 2, /* esel (a.k.a tlb_index*/
- BOOKE_PAGESZ_1M, /* tsize ie 2^10kB ie 1MB */
- 1);
-
- /// amlal:
- /// map pci base for kernel
- cb_set_tlb(0, CB_BASE_ADDRESS, /* v_addr, 0xFE008000 */
- 0xFE0008000, /* p_addr. 0xfe0000000 */
- MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
- MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
- 0, /* ts i.e AS=0 */
- 3, /* esel (a.k.a tlb_index*/
- BOOKE_PAGESZ_1M, /* tsize ie 2^10kB ie 1MB */
- 1);
-
- cb_pci_init_tree();
-
- cb_pci_append_tree("@fb", CB_FRAMEBUFFER_ADDR, 0x0);
- cb_pci_append_tree("@mbci", 0x0, 0x0); // did not found a MBCI base for now...
- cb_pci_append_tree("@serial", CB_UART_BASE, 0);
- cb_pci_append_tree("@pci", CB_BASE_ADDRESS, 0x0);
-
- cb_flush_tlb();
+void cb_init_hw(void) {
+ /// amlal:
+ /// map VGA framebuffer
+ cb_set_tlb(0, CB_FRAMEBUFFER_ADDR, /* v_addr, 0x0000A0000 */
+ 0x0000A000, /* p_addr. 0x0000A0000 */
+ MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
+ MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
+ 0, /* ts i.e AS=0 */
+ 1, /* esel (a.k.a tlb_index*/
+ BOOKE_PAGESZ_64K, /* tsize ie 2^10kB ie 1MB */
+ 1);
+
+ // map ccsrbar and uart.
+ // at start we execute from esel = 0, so chose something else..
+ cb_set_tlb(1, CB_UART_BASE, /* v_addr 0xe0000000 see qemu-ppce500.h */
+ 0xfe0000000, /* p_addr. 0xfe0000000 */
+ MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
+ MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
+ 0, /* ts i.e AS=0 */
+ 2, /* esel (a.k.a tlb_index*/
+ BOOKE_PAGESZ_1M, /* tsize ie 2^10kB ie 1MB */
+ 1);
+
+ /// amlal:
+ /// map pci base for kernel
+ cb_set_tlb(0, CB_BASE_ADDRESS, /* v_addr, 0xFE008000 */
+ 0xFE0008000, /* p_addr. 0xfe0000000 */
+ MAS3_SW | MAS3_SR, /* perm type=TLB_MAP_IO */
+ MAS2_I | MAS2_G, /* wimge type=TLB_MAP_IO */
+ 0, /* ts i.e AS=0 */
+ 3, /* esel (a.k.a tlb_index*/
+ BOOKE_PAGESZ_1M, /* tsize ie 2^10kB ie 1MB */
+ 1);
+
+ cb_pci_init_tree();
+
+ cb_pci_append_tree("@fb", CB_FRAMEBUFFER_ADDR, 0x0);
+ cb_pci_append_tree("@mbci", 0x0, 0x0); // did not found a MBCI base for now...
+ cb_pci_append_tree("@serial", CB_UART_BASE, 0);
+ cb_pci_append_tree("@pci", CB_BASE_ADDRESS, 0x0);
+
+ cb_flush_tlb();
}
-void cb_flush_tlb(void)
-{
- asm volatile("isync;tlbwe;msync;isync");
+void cb_flush_tlb(void) {
+ asm volatile("isync;tlbwe;msync;isync");
};
diff --git a/src/ppc64/ppc64-uart.c b/src/ppc64/ppc64-uart.c index c908eae..c16657d 100644 --- a/src/ppc64/ppc64-uart.c +++ b/src/ppc64/ppc64-uart.c @@ -1,48 +1,43 @@ /* -------------------------------------------
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
-#include <lib/string.h>
#include <lib/boot.h>
+#include <lib/string.h>
/// BUGS: 0
#define CB_NS16550_COM1 (CB_UART_BASE + 0x4500)
#define CB_NS16550_COM2 (CB_UART_BASE + 0x4600)
-volatile ascii_char_t* const UART0DR = (ascii_char_t*)CB_NS16550_COM1;
+volatile ascii_char_t* const UART0DR = (ascii_char_t*) CB_NS16550_COM1;
/* this file handles the UART */
/// @brief Get character from UART.
/// @param
/// @return
-utf_char_t cb_get_char(void)
-{
- while (!(*(((volatile uint8_t*)UART0DR) + 0x05) & 0x01))
- ;
- return (utf_char_t)*UART0DR;
+utf_char_t cb_get_char(void) {
+ while (!(*(((volatile uint8_t*) UART0DR) + 0x05) & 0x01));
+ return (utf_char_t) *UART0DR;
}
/// @brief Put character into UART.
/// @param ch
-void cb_put_char(utf_char_t ch)
-{
- *UART0DR = (ascii_char_t)(ch);
+void cb_put_char(utf_char_t ch) {
+ *UART0DR = (ascii_char_t) (ch);
}
/// @brief Put string in UART.
/// @param text the input text.
-size_t cb_put_string(const char* text)
-{
- while (*text != '\0')
- { /* Loop until end of string */
+size_t cb_put_string(const char* text) {
+ while (*text != '\0') { /* Loop until end of string */
- cb_put_char(*text); /* Transmit char */
+ cb_put_char(*text); /* Transmit char */
- text++; /* Next char */
- }
- return 0;
+ text++; /* Next char */
+ }
+ return 0;
}
diff --git a/src/rv64/rv64-err.c b/src/rv64/rv64-err.c index 19d0f3c..a616d83 100644 --- a/src/rv64/rv64-err.c +++ b/src/rv64/rv64-err.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,14 +10,12 @@ /// @brief Goes into a panic state. /// @param reason why? -void cb_panic(const char* reason) -{ - cb_put_string("Error: "); - cb_put_string(reason); - cb_put_char('\n'); +void cb_panic(const char* reason) { + cb_put_string("Error: "); + cb_put_string(reason); + cb_put_char('\n'); - while (yes) - { - asm volatile("wfi"); - } + while (yes) { + asm volatile("wfi"); + } } diff --git a/src/rv64/rv64-uart.c b/src/rv64/rv64-uart.c index 0bc6517..a859add 100644 --- a/src/rv64/rv64-uart.c +++ b/src/rv64/rv64-uart.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -11,51 +11,43 @@ /* this file handles the UART */ -static uint8_t* cb_uart_ptr = (uint8_t*)CB_UART_BASE; +static uint8_t* cb_uart_ptr = (uint8_t*) CB_UART_BASE; -utf_char_t cb_get_char(void) -{ - uintptr_t ptr = CB_UART_BASE; +utf_char_t cb_get_char(void) { + uintptr_t ptr = CB_UART_BASE; - while (!(*(((volatile uint8_t*)ptr) + 0x05) & 0x01)) - ; + while (!(*(((volatile uint8_t*) ptr) + 0x05) & 0x01)); - return (utf_char_t)*cb_uart_ptr; + return (utf_char_t) *cb_uart_ptr; } // we need that one, to avoid sending mutliple chars to UART. static boolean cb_locked_put_char = no; -void cb_put_char(utf_char_t ch) -{ - int32_t timeout = 0; +void cb_put_char(utf_char_t ch) { + int32_t timeout = 0; - while (cb_locked_put_char) - { - ++timeout; + while (cb_locked_put_char) { + ++timeout; - if (timeout > 1000000) - break; - } + if (timeout > 1000000) break; + } - cb_locked_put_char = yes; - *cb_uart_ptr = ch; - cb_locked_put_char = no; + cb_locked_put_char = yes; + *cb_uart_ptr = ch; + cb_locked_put_char = no; } /// @brief UART put string /// @param text the input text. -size_t cb_put_string(const char* text) -{ - if (text == nil) - return 0; +size_t cb_put_string(const char* text) { + if (text == nil) return 0; - size_t i = 0; + size_t i = 0; - for (; i < strlen(text); i++) - { - cb_put_char(text[i]); - } + for (; i < strlen(text); i++) { + cb_put_char(text[i]); + } - return i; + return i; } |
