/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */
#ifndef __MMU_H__
#define __MMU_H__

/*
 * Control Register C1.
 */
#define ENABLE_MMU             0x00000001
#define ENABLE_ALIGNMENT_CHECK 0x00000002
#define ENABLE_D_CACHE	       0x00000004
#define BIG_ENDIAN             0x00000080
#define SYS_PROT_RO            0x00000100
#define ROM_PROT_RO            0x00000200
#define ENABLE_I_CACHE         0x00001000
#define HIGH_VECTORS           0x00002000
#define RR_CACHE               0x00004000
#define L4_BIT                 0x00008000

/*
 * Control Register C2.
 *
 * First level section table.
 * Note: there is also ann other TTB definition in cache/mmu1.s and mmu2.s
 *
 */
#define TRANS_TABLE_ADDR     0xfff08000
#define TRANS_TABLE_SIZE     4096

/*
 * This is a section prototype.  The base address should be masked
 * into the top 12 bits.  That is, the input top 12 bits of the
 * virtual address are used to look up the entry in the translation
 * table, and the top 12 bits of the entry become the top 12 bits of
 * the output physical address.  Since there is no secondary page
 * table, that's it.
 */
#define TENTRY_SECTION        0x00000012
#define B_BIT_SECTION         0x00000004
#define C_BIT_SECTION         0x00000008
#define NO_ACC_SECTION        0x00000400
#define RO_SECTION            0x00000800
#define RW_SECTION            0x00000C00

#define INVALID_SECTION       0x00000c10
#define NONBUFFERED_SECTION   (RW_SECTION | TENTRY_SECTION)
#define NONCACHED_SECTION     (RW_SECTION | B_BIT_SECTION | TENTRY_SECTION)
#define WRITETHROUGH_SECTION  (RW_SECTION | C_BIT_SECTION | TENTRY_SECTION)
#define WRITEBACK_SECTION     (RW_SECTION | B_BIT_SECTION | C_BIT_SECTION | TENTRY_SECTION)
#define SECTION_ADDR_MASK     0xfff00000

/*
 * This is a coarse page entry prototype.  The base address of the
 * secondary page table should be masked into the top 22 bits.  That
 * is, the input top 12 bits of the virtual address are used to look
 * up the entry in the translation table, and the top 22 bits of the
 * entry point to the page table from where come the top 12 bits of
 * the output physical address.
 */
#define COARSE_TT_ENTRY      0x00000011
#define COARSE_ADDR_MASK     0xfffffe00
#define COARSE_PT_SIZE       256

/*
 * This is a fine page entry prototype.  The base address of the
 * secondary page table should be masked into the top 20 bits.  That
 * is, the input top 12 bits of the virtual address are used to look
 * up the entry in the translation table, and the top 20 bits of the
 * entry point to the page table from where come the top 12 bits of
 * the output physical address.
 */
#define FINE_TT_ENTRY        0x00000013
#define FINE_ADDR_MASK       0xfffff800
#define FINE_PT_SIZE         1024
#define ACCESS_NONE          0x0
#define ACCESS_CLIENT        0x1
#define ACCESS_RSVD          0x2
#define ACCESS_MGR           0x3

/*
 * Page Table
 */
#define PT_ADDR              (TRANS_TABLE_ADDR + (TRANS_TABLE_SIZE \
						  * sizeof (unsigned int)))
#define FINE_PT            0x1
#define COARSE_PT          0x0
#define BUFFERED_PT        0x1
#define UNBUFFERED_PT      0x0
#define CACHED_PT          0x1
#define UNCACHED_PT        0x0

/*
 * Large page descriptor.  The 16 most significant bits of the
 * physical address should be masked into bits [31:16].   The
 * B (buffer) bit is bit[2] and the C (cache) bit is bit[3].
 */
#define LARGE_PAGE          0x00000001
#define LARGE_PT_MASK       0xffff0000
#define LARGE_PT_INCR       0x00010000
#define LARGE_PT_MGR        0x00000ff0

/*
 * Small page descriptor.  The 20 most significant bits of the
 * physical address should be masked into bits [31:12].   The
 * B (buffer) bit is bit[2] and the C (cache) bit is bit[3].
 */
#define SMALL_PAGE          0x00000002
#define SMALL_PT_MASK       0xfffff000
#define SMALL_PT_INCR       0x00001000
#define SMALL_PT_MGR        0x00000ff0

/*
 * Tine page descriptor.  The 20 most significant bits of the
 * physical address should be masked into bits [31:10].   The
 * B (buffer) bit is bit[2] and the C (cache) bit is bit[3].
 */
#define TINY_PAGE           0x00000003
#define TINY_PT_MASK        0xfffffc00
#define TINY_PT_INCR        0x00000400
#define TINY_PT_MGR         0x00000030


/*
 * Control Register C3
 */
#define DOMAIN_NO_ACCESS      0x00000000
#define DOMAIN_CLIENT_ACCESS  0x55555555
#define DOMAIN_MANAGER_ACCESS 0xffffffff

#endif /* __MMU_H__ */
