Fixed bug by increasing stride.

Fixed bug by increasing stride.

The goal of this script is to find the first index of a char in a given array
This allows conversion of a string into the number with the array used to
decode the base

The layout is given
0x00 to 0x03 is the output position; it also holds previous digit value
0x04 to 0x07 and 0x08 to 0x0B is the decimal place multiplier
0x10 to 0x13 is the char to be decoded
0x14 onwards is the char array where index gives decoding value

 0x00   0x01   0x02   0x03   0x04   0x05   0x06   0x07
(0x01) (0x1V) (0x01) (0x2V) (0x01) (0x1X) (0x01) (0x2X)

 0x08   0x09   0x0A   0x1B   0x0C   0x0D   0x0E   0x0F
(0x01) (0x1X) (0x01) (0x2X) (0x01) (0x1Y) (0x01) (0x2Y)

 0x10   0x11   0x12   0x13   0x14   0x15   0x16   0x17
(0x01) (0x00) (0x01) (0x2Z) (0x00) (0x00) (0x00) (0x30)
 ^
 0x18   0x19   0x1A   0x1B   0x1C   0x1D   0x1E   0x1F
(0x00) (0x00) (0x00) (0x31) (0x00) (0x00) (0x00) (0x32)  and so on

Start by zeroing out 0x0E 0x10 and 0x12
<<[-]>>[-]>>[-]

Copy 0x13 to 0x10 ending at 0x12
>[-<+<<+>>>]<[->+<]+

start a loop
[
  for ease of explanation we look at the case where index starts at 0x12
  [-]                            zero out 0x12
  go to 0x17 setting 0x15 to zero as we pass
  >>>[-]>>                       go to 0x17 set 0x15 to zero as we pass
  [-<+<+>>]<<[->>+<<]            copy 0x17 to 0x16 finish at 0x15
  <<<<<                          go to 0x10
  [->>>>+>>-<<<<<<]              sub value 0x2Z at index 0x10 from 0x16
                                 also set 0x14 to 0x2Z
                                 if 0x16 holds 0 then cell 0x13 == cell 0x17
				 end at 0x10
  >[->>>>+<<<<]                  move 0x11 to 0x15
  >>>>+                          increment 0x15
  now leave a trail of 1s to follow back
  <<<+<<+>>>>>                  set 0x10 0x12 to 1
  >
]
remove original decode char
<<<<[<<]>>>>>[-]<[>>]
copy back
< [-<<<[<<]>>>>>+<[>>]<]

The goal of this script is to find the first index of a char in a given array
This allows conversion of a string into the number with the array used to
decode the base

The layout is given
0x00 to 0x03 is the output position; it also holds previous digit value
0x04 to 0x07 and 0x08 to 0x0B is the decimal place multiplier
0x10 to 0x13 is the char to be decoded
0x14 onwards is the char array where index gives decoding value

 0x00   0x01   0x02   0x03   0x04   0x05   0x06   0x07
(0x01) (0x1V) (0x01) (0x2V) (0x01) (0x1X) (0x01) (0x2X)

 0x08   0x09   0x0A   0x1B   0x0C   0x0D   0x0E   0x0F
(0x01) (0x1X) (0x01) (0x2X) (0x01) (0x1Y) (0x01) (0x2Y)

 0x10   0x11   0x12   0x13   0x14   0x15   0x16   0x17
(0x01) (0x00) (0x01) (0x2Z) (0x00) (0x00) (0x00) (0x30)
 ^
 0x18   0x19   0x1A   0x1B   0x1C   0x1D   0x1E   0x1F
(0x00) (0x00) (0x00) (0x31) (0x00) (0x00) (0x00) (0x32)  and so on

Start by zeroing out 0x0E 0x10 and 0x12
<<[-]>>[-]>>[-]

Copy 0x13 to 0x10 ending at 0x12
>[-<+<<+>>>]<[->+<]+

start a loop
[
  for ease of explanation we look at the case where index starts at 0x12
  [-]                            zero out 0x12
  go to 0x17 setting 0x15 to zero as we pass
  >>>[-]>>                       go to 0x17 set 0x15 to zero as we pass
  [-<+<+>>]<<[->>+<<]            copy 0x17 to 0x16 finish at 0x15
  <<<<<                          go to 0x10
  [->>>>+>>-<<<<<<]              sub value 0x2Z at index 0x10 from 0x16
                                 also set 0x14 to 0x2Z
                                 if 0x16 holds 0 then cell 0x13 == cell 0x17
				 end at 0x10
  >[->>>>+<<<<]                  move 0x11 to 0x15
  >>>>+                          increment 0x15
  now leave a trail of 1s to follow back
  <<<<+<<+>>>>>                  set 0x10 0x12 to 1
  >
]
remove original decode char
<<<<[<<]>>>>>[-]<[>>]
copy back
< [-<<<[<<]>>>>>+<[>>]<]


patch from Leon to undo the extra brainfuck that perl.org's mailer wrote

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@2671 d31e2699-5ff4-0310-a27c-f18f2fbe73fe


x64: extend message_info_t to 64-bit

x64: extend message_info_t to 64-bit

--
-- Copyright 2014, General Dynamics C4 Systems
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(GD_GPL)
--

#if defined(__KERNEL_32__)

base 32

-- Cap rights
block cap_rights {
    padding 29
    field capAllowGrant 1
    field capAllowRead 1
    field capAllowWrite 1
}

#elif defined(__KERNEL_64__)

base 64

-- Cap rights
block cap_rights {
    padding 32

    padding 29
    field capAllowGrant 1
    field capAllowRead 1
    field capAllowWrite 1
}

#else

#error "typesbf unsupported kernel word size"
#endif

--
-- Copyright 2014, General Dynamics C4 Systems
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(GD_GPL)
--

base 32

-- Cap rights
block cap_rights {
    padding 29
    field capAllowGrant 1
    field capAllowRead 1
    field capAllowWrite 1
}


Updated Example-CellSize.bf

Updated Example-CellSize.bf


SELFOUR-560: Remove unused io_page_directory cap

--
-- Copyright 2014, General Dynamics C4 Systems
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(GD_GPL)
--

#include <config.h>
-- Default base size: uint32_t
base 32

-- Including the common structures_32.bf is neccessary because
-- we need the structures to be visible here when building
-- the capType
#include <object/structures_32.bf>

---- ARM-specific caps

-- 4k frame (these have a separate cap type as there is no room to
-- store their size)
block small_frame_cap {
    field capFMappedASIDLow 10
    field capFVMRights       2
    field_high capFMappedAddress 20

#ifdef CONFIG_ARM_SMMU
    field capFIsIOSpace      1
    field capFMappedASIDHigh 7
#else
    field capFMappedASIDHigh 8
#endif
    field_high capFBasePtr  20
    field capType            4
}

-- 64k, 1M, 16M frames
block frame_cap {
    field capFSize           2
    field capFMappedASIDLow 10
    field capFVMRights       2
    field_high capFMappedAddress 18

    padding                  2
    field capFMappedASIDHigh 8
    field_high capFBasePtr  18
    field capType            4
}

-- Second-level page table
block page_table_cap {
    padding                   1
    field capPTIsMapped       1
    field capPTMappedASID    18
#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
    field_high capPTMappedAddress 12
#else
    padding                   1
    field_high capPTMappedAddress 11
#endif

    field_high capPTBasePtr  22
    padding                   6
    field capType             4
}

-- First-level page table (page directory)
block page_directory_cap(capPDMappedASID, capPDIsMapped,
                         capPDBasePtr, capType) {
    padding                 14
    field capPDMappedASID   18

    field_high capPDBasePtr 18
    padding                  9
    field capPDIsMapped      1
    field capType            4
}

-- Cap to the table of 2^8 ASID pools
block asid_control_cap {
    padding       32

    padding       28
    field capType  4
}

-- Cap to a pool of 2^10 asids
block asid_pool_cap {
    padding                14
    field capASIDBase      18

    field_high capASIDPool 28
    field capType          4
}

#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
block vcpu_cap {
    padding               32

    field_high capVCPUPtr 24
    field capType         8
}
#endif

#ifdef CONFIG_ARM_SMMU
-- IO space caps
-- each module has an engine that can be enabled
-- the clients use the same module can be separately enabled
block io_space_cap {
    field   capModuleID       16
    field   capClientID       16

    padding                   24
    field   capType           8
}

block io_space_capdata {
    padding                 32

    field   moduleID        16
    field   clientID        16
}

block io_page_table_cap (capType, capIOPTIsMapped, capIOPTASID, capIOPTBasePtr, capIOPTMappedAddress) {
    field_high  capIOPTBasePtr          20
    padding                             12

    field_high  capIOPTMappedAddress    10
    padding                             6
    field       capIOPTASID             7
    field       capIOPTIsMapped         1
    field       capType                 8
}
#endif

-- NB: odd numbers are arch caps (see isArchCap())
tagged_union cap capType {
    mask 4 0xe
    mask 8 0x0e

    -- 4-bit tag caps
    tag null_cap             0
    tag untyped_cap          2
    tag endpoint_cap         4
    tag notification_cap     6
    tag reply_cap            8
    tag cnode_cap           10
    tag thread_cap          12
    -- Do not extend even 4-bit caps types beyond 12, as we use
    -- 14 (0xe) to determine which caps are 8-bit.

    -- 4-bit tag arch caps
    tag small_frame_cap      1
    tag frame_cap            3
    tag asid_pool_cap        5
    tag page_table_cap       7
    tag page_directory_cap   9
    tag asid_control_cap    11
    -- Do not extend odd 4-bit caps types beyond 13, as we use
    -- 15 (0xf) to determine which caps are 8-bit.

    -- 8-bit tag caps
    tag irq_control_cap     0x0e
    tag irq_handler_cap     0x1e
    tag zombie_cap          0x2e
    tag domain_cap          0x3e

    -- 8-bit tag arch caps
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    tag vcpu_cap            0x0f
#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */

    -- we use the same names as for x86 IOMMU caps
#ifdef CONFIG_ARM_SMMU
    tag io_space_cap            0x1f
    tag io_page_table_cap       0x2f
#endif
}

---- Arch-independent object types

block vm_fault {
    field address 32
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    field FSR 26
    padding 2
    field instructionFault 1
#else
    field FSR 14
    field instructionFault 1
    padding 14
#endif
    field faultType 3
}

#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
block vgic_maintenance {
    field idx        6
    field idxValid   1
    padding         25
    padding         29
    field faultType  3
}

block vcpu_fault {
    field hsr       32
    padding         29
    field faultType  3
}
#endif

tagged_union fault faultType {
    tag null_fault 0
    tag cap_fault 1
    tag vm_fault 2
    tag unknown_syscall 3
    tag user_exception 4
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    tag vgic_maintenance 5
    tag vcpu_fault       6
#endif
}

---- ARM-specific object types

block stored_hw_asid {
    field asid 8
    field valid 1
    padding 21
    field pdeType 2
}

#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
-- Short descriptors

-- Page directory entries
block pde_invalid {
    field stored_hw_asid 8
    field stored_asid_valid 1
    padding 21
    field pdeType 2
}

block pde_coarse {
    field_high address 22
    field P 1
    field Domain 4
    padding 3
    field pdeType 2
}

block pde_section {
    field_high address 12
    padding 1
    field size 1
    field nG 1
    field S 1
    field APX 1
    field TEX 3
    field AP 2
    field P 1
    field Domain 4
    field XN 1
    field C 1
    field B 1
    field pdeType 2
}

block pde_reserved {
    padding 30
    field pdeType 2
}

tagged_union pde pdeType {
    tag pde_invalid 0
    tag pde_coarse 1
    tag pde_section 2
    tag pde_reserved 3
}

-- Page table entries
block pte_large {
    field_high address 16
    field XN 1
    field TEX 3
    field nG 1
    field S 1
    field APX 1
    padding 3
    field AP 2
    field C 1
    field B 1
    field pteSize 1
    field reserved 1 -- must be set
}

block pte_small {
    field_high address 20
    field nG 1
    field S 1
    field APX 1
    field TEX 3
    field AP 2
    field C 1
    field B 1
    field pteSize 1
    field XN 1
}

tagged_union pte pteSize {
    tag pte_large 0
    tag pte_small 1
}

#else /* CONFIG_ARM_HYPERVISOR_SUPPORT */
-- These #defines allow for writing the bitfields here such
-- that they match the names in the ARM hardware, yet can
-- be used transparently by the existing C code that was
-- written for the short descriptors
#define pdeS2         pde
#define pdeS2Type     pdeType
#define pdeS2_section pde_section
#define pdeS2_coarse  pde_coarse
#define pdeS2_invalid pde_invalid

#define pteS2         pte
#define pteS2Type     pteType
#define pteS2_small   pte_small
#define pteS2_invalid pte_invalid

-- Stage 2 Long descriptors
-- Page directory entries

block pdeS2_invalid {
    padding 32
    field stored_hw_asid 8
    field stored_asid_valid 1
    padding 21
    field pdeS2Type 2
}

block pdeS2_section {
    padding 9
    field XN 1
    padding 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    padding 1
    field AF 1
    field SH 2
    field HAP 2
    field MemAttr 4
    field pdeS2Type 2
}

block pdeS2_coarse {
    padding 24
    padding 8
    field_high address 20
    padding 10
    field pdeS2Type 2
}

tagged_union pdeS2 pdeS2Type {
    tag pdeS2_invalid  0
    tag pdeS2_section  1
    tag pdeS2_coarse   3
}

-- Page table entries
block pteS2_invalid {
    padding 62
    field pteS2Type 2
}

block pteS2_small {
    padding 9
    field XN 1
    padding 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    padding 1
    field AF 1
    field SH 2
    field HAP 2
    field MemAttr 4
    field pteS2Type 2
}

tagged_union pteS2 pteS2Type {
    tag pteS2_invalid  0
    tag pteS2_small    3
}

-- Stage 1
-- Page directory entries
block pdeS1_invalid {
    padding 62
    field pdeS1Type 2
}

block pdeS1_section {
    padding 9
    field XN 1
    field PXN 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    field nG 1
    field AF 1
    field SH 2
    field AP 2
    field NS 1
    field AttrIndx 3
    field pdeS1Type 2
}

block pdeS1_coarse {
    field NSTable 1
    field APTable 2
    field XNTable 1
    field PXNTable 1
    padding 19
    padding 8
    field_high address 20
    padding 10
    field pdeS1Type 2
}

tagged_union pdeS1 pdeS1Type {
    tag pdeS1_invalid  0
    tag pdeS1_section  1
    tag pdeS1_coarse   3
}

-- Page table entries
block pteS1_invalid {
    padding 62
    field pteS1Type 2
}

block pteS1_small {
    padding 9
    field XN 1
    field PXN 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    field nG 1
    field AF 1
    field SH 2
    field AP 2
    field NS 1
    field AttrIndx 3
    field pteS1Type 2
}

tagged_union pteS1 pteS1Type {
    tag pteS1_invalid  0
    tag pteS1_small    3
}

#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */

-- VM attributes

block vm_attributes {
    padding 29
    field armExecuteNever  1
    field armParityEnabled 1
    field armPageCacheable 1
}

--
-- Copyright 2014, General Dynamics C4 Systems
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(GD_GPL)
--

#include <config.h>
-- Default base size: uint32_t
base 32

-- Including the common structures_32.bf is neccessary because
-- we need the structures to be visible here when building
-- the capType
#include <object/structures_32.bf>

---- ARM-specific caps

-- 4k frame (these have a separate cap type as there is no room to
-- store their size)
block small_frame_cap {
    field capFMappedASIDLow 10
    field capFVMRights       2
    field_high capFMappedAddress 20

#ifdef CONFIG_ARM_SMMU
    field capFIsIOSpace      1
    field capFMappedASIDHigh 7
#else
    field capFMappedASIDHigh 8
#endif
    field_high capFBasePtr  20
    field capType            4
}

-- 64k, 1M, 16M frames
block frame_cap {
    field capFSize           2
    field capFMappedASIDLow 10
    field capFVMRights       2
    field_high capFMappedAddress 18

    padding                  2
    field capFMappedASIDHigh 8
    field_high capFBasePtr  18
    field capType            4
}

-- Second-level page table
block page_table_cap {
    padding                   1
    field capPTIsMapped       1
    field capPTMappedASID    18
#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
    field_high capPTMappedAddress 12
#else
    padding                   1
    field_high capPTMappedAddress 11
#endif

    field_high capPTBasePtr  22
    padding                   6
    field capType             4
}

-- First-level page table (page directory)
block page_directory_cap(capPDMappedASID, capPDIsMapped,
                         capPDBasePtr, capType) {
    padding                 14
    field capPDMappedASID   18

    field_high capPDBasePtr 18
    padding                  9
    field capPDIsMapped      1
    field capType            4
}

-- Cap to the table of 2^8 ASID pools
block asid_control_cap {
    padding       32

    padding       28
    field capType  4
}

-- Cap to a pool of 2^10 asids
block asid_pool_cap {
    padding                14
    field capASIDBase      18

    field_high capASIDPool 28
    field capType          4
}

#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
block vcpu_cap {
    padding               32

    field_high capVCPUPtr 24
    field capType         8
}
#endif

#ifdef CONFIG_ARM_SMMU
-- IO space caps
-- each module has an engine that can be enabled
-- the clients use the same module can be separately enabled
block io_space_cap {
    field   capModuleID       16
    field   capClientID       16

    padding                   24
    field   capType           8
}

block io_space_capdata {
    padding                 32

    field   moduleID        16
    field   clientID        16
}

block io_page_directory_cap (capType, capIOPDIsMapped, capIOPDASID, capIOPDBasePtr) {
    field_high  capIOPDBasePtr      20
    padding                         12

    padding                         16
    field       capIOPDASID         7       -- TK1 has 7-bit ASID
    field       capIOPDIsMapped     1
    field       capType             8
}

block io_page_table_cap (capType, capIOPTIsMapped, capIOPTASID, capIOPTBasePtr, capIOPTMappedAddress) {
    field_high  capIOPTBasePtr          20
    padding                             12

    field_high  capIOPTMappedAddress    10
    padding                             6
    field       capIOPTASID             7
    field       capIOPTIsMapped         1
    field       capType                 8
}
#endif

-- NB: odd numbers are arch caps (see isArchCap())
tagged_union cap capType {
    mask 4 0xe
    mask 8 0x0e

    -- 4-bit tag caps
    tag null_cap             0
    tag untyped_cap          2
    tag endpoint_cap         4
    tag notification_cap     6
    tag reply_cap            8
    tag cnode_cap           10
    tag thread_cap          12
    -- Do not extend even 4-bit caps types beyond 12, as we use
    -- 14 (0xe) to determine which caps are 8-bit.

    -- 4-bit tag arch caps
    tag small_frame_cap      1
    tag frame_cap            3
    tag asid_pool_cap        5
    tag page_table_cap       7
    tag page_directory_cap   9
    tag asid_control_cap    11
    -- Do not extend odd 4-bit caps types beyond 13, as we use
    -- 15 (0xf) to determine which caps are 8-bit.

    -- 8-bit tag caps
    tag irq_control_cap     0x0e
    tag irq_handler_cap     0x1e
    tag zombie_cap          0x2e
    tag domain_cap          0x3e

    -- 8-bit tag arch caps
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    tag vcpu_cap            0x0f
#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */

    -- we use the same names as for x86 IOMMU caps
#ifdef CONFIG_ARM_SMMU
    tag io_space_cap            0x1f
    tag io_page_directory_cap   0x2f
    tag io_page_table_cap       0x3f
#endif
}

---- Arch-independent object types

block vm_fault {
    field address 32
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    field FSR 26
    padding 2
    field instructionFault 1
#else
    field FSR 14
    field instructionFault 1
    padding 14
#endif
    field faultType 3
}

#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
block vgic_maintenance {
    field idx        6
    field idxValid   1
    padding         25
    padding         29
    field faultType  3
}

block vcpu_fault {
    field hsr       32
    padding         29
    field faultType  3
}
#endif

tagged_union fault faultType {
    tag null_fault 0
    tag cap_fault 1
    tag vm_fault 2
    tag unknown_syscall 3
    tag user_exception 4
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
    tag vgic_maintenance 5
    tag vcpu_fault       6
#endif
}

---- ARM-specific object types

block stored_hw_asid {
    field asid 8
    field valid 1
    padding 21
    field pdeType 2
}

#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
-- Short descriptors

-- Page directory entries
block pde_invalid {
    field stored_hw_asid 8
    field stored_asid_valid 1
    padding 21
    field pdeType 2
}

block pde_coarse {
    field_high address 22
    field P 1
    field Domain 4
    padding 3
    field pdeType 2
}

block pde_section {
    field_high address 12
    padding 1
    field size 1
    field nG 1
    field S 1
    field APX 1
    field TEX 3
    field AP 2
    field P 1
    field Domain 4
    field XN 1
    field C 1
    field B 1
    field pdeType 2
}

block pde_reserved {
    padding 30
    field pdeType 2
}

tagged_union pde pdeType {
    tag pde_invalid 0
    tag pde_coarse 1
    tag pde_section 2
    tag pde_reserved 3
}

-- Page table entries
block pte_large {
    field_high address 16
    field XN 1
    field TEX 3
    field nG 1
    field S 1
    field APX 1
    padding 3
    field AP 2
    field C 1
    field B 1
    field pteSize 1
    field reserved 1 -- must be set
}

block pte_small {
    field_high address 20
    field nG 1
    field S 1
    field APX 1
    field TEX 3
    field AP 2
    field C 1
    field B 1
    field pteSize 1
    field XN 1
}

tagged_union pte pteSize {
    tag pte_large 0
    tag pte_small 1
}

#else /* CONFIG_ARM_HYPERVISOR_SUPPORT */
-- These #defines allow for writing the bitfields here such
-- that they match the names in the ARM hardware, yet can
-- be used transparently by the existing C code that was
-- written for the short descriptors
#define pdeS2         pde
#define pdeS2Type     pdeType
#define pdeS2_section pde_section
#define pdeS2_coarse  pde_coarse
#define pdeS2_invalid pde_invalid

#define pteS2         pte
#define pteS2Type     pteType
#define pteS2_small   pte_small
#define pteS2_invalid pte_invalid

-- Stage 2 Long descriptors
-- Page directory entries

block pdeS2_invalid {
    padding 32
    field stored_hw_asid 8
    field stored_asid_valid 1
    padding 21
    field pdeS2Type 2
}

block pdeS2_section {
    padding 9
    field XN 1
    padding 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    padding 1
    field AF 1
    field SH 2
    field HAP 2
    field MemAttr 4
    field pdeS2Type 2
}

block pdeS2_coarse {
    padding 24
    padding 8
    field_high address 20
    padding 10
    field pdeS2Type 2
}

tagged_union pdeS2 pdeS2Type {
    tag pdeS2_invalid  0
    tag pdeS2_section  1
    tag pdeS2_coarse   3
}

-- Page table entries
block pteS2_invalid {
    padding 62
    field pteS2Type 2
}

block pteS2_small {
    padding 9
    field XN 1
    padding 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    padding 1
    field AF 1
    field SH 2
    field HAP 2
    field MemAttr 4
    field pteS2Type 2
}

tagged_union pteS2 pteS2Type {
    tag pteS2_invalid  0
    tag pteS2_small    3
}

-- Stage 1
-- Page directory entries
block pdeS1_invalid {
    padding 62
    field pdeS1Type 2
}

block pdeS1_section {
    padding 9
    field XN 1
    field PXN 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    field nG 1
    field AF 1
    field SH 2
    field AP 2
    field NS 1
    field AttrIndx 3
    field pdeS1Type 2
}

block pdeS1_coarse {
    field NSTable 1
    field APTable 2
    field XNTable 1
    field PXNTable 1
    padding 19
    padding 8
    field_high address 20
    padding 10
    field pdeS1Type 2
}

tagged_union pdeS1 pdeS1Type {
    tag pdeS1_invalid  0
    tag pdeS1_section  1
    tag pdeS1_coarse   3
}

-- Page table entries
block pteS1_invalid {
    padding 62
    field pteS1Type 2
}

block pteS1_small {
    padding 9
    field XN 1
    field PXN 1
    field contiguous_hint 1
    padding 12
    padding 8
    field_high address 20
    field nG 1
    field AF 1
    field SH 2
    field AP 2
    field NS 1
    field AttrIndx 3
    field pteS1Type 2
}

tagged_union pteS1 pteS1Type {
    tag pteS1_invalid  0
    tag pteS1_small    3
}

#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */

-- VM attributes

block vm_attributes {
    padding 29
    field armExecuteNever  1
    field armParityEnabled 1
    field armPageCacheable 1
}


Make rot13 executable as a script.

Make rot13 executable as a script.

#!/usr/bin/env brainmuk

[
    Obtained from:
    https://en.wikipedia.org/wiki/Brainfuck#ROT13
]

-,+[                         Read first character and start outer character reading loop
    -[                       Skip forward if character is 0
        >>++++[>++++++++<-]  Set up divisor (32) for division loop
                               (MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)
        <+<-[                Set up dividend (x minus 1) and enter division loop
            >+>+>-[>>>]      Increase copy and remainder / reduce divisor / Normal case: skip forward
            <[[>+<-]>>+>]    Special case: move remainder back to divisor and increase quotient
            <<<<<-           Decrement dividend
        ]                    End division loop
    ]>>>[-]+                 End skip loop; zero former divisor and reuse space for a flag
    >--[-[<->+++[-]]]<[         Zero that flag unless quotient was 2 or 3; zero quotient; check flag
        ++++++++++++<[       If flag then set up divisor (13) for second division loop
                               (MEMORY LAYOUT: zero copy dividend divisor remainder quotient zero zero)
            >-[>+>>]         Reduce divisor; Normal case: increase remainder
            >[+[<+>-]>+>>]   Special case: increase remainder / move it back to divisor / increase quotient
            <<<<<-           Decrease dividend
        ]                    End division loop
        >>[<+>-]             Add remainder back to divisor to get a useful 13
        >[                   Skip forward if quotient was 0
            -[               Decrement quotient and skip forward if quotient was 1
                -<<[-]>>     Zero quotient and divisor if quotient was 2
            ]<<[<<->>-]>>    Zero divisor and subtract 13 from copy if quotient was 1
        ]<<[<<+>>-]          Zero divisor and add 13 to copy if quotient was 0
    ]                        End outer skip loop (jump to here if ((character minus 1)/32) was not 2 or 3)
    <[-]                     Clear remainder from first division if second division was skipped
    <.[-]                    Output ROT13ed character from copy and clear it
    <-,+                     Read next character
]                            End character reading loop


Update bottles.bf

Update bottles.bf


Fixing bug in alphabet.bf

Fixing bug in alphabet.bf

[Print the alphabet (A-Z)]

[Leave data location 0 with value 0 to allow comments]
>

[Initialize the loop variable to 26, the length of the alphabet]
++++++++++
++++++++++
++++++

< [Initialize the character to be printed to 66, the value of A]
>>
++++++++++
++++++++++
++++++++++
++++++++++
++++++++++
++++++++++
+++++

<< [Loop body: print char, increment char, decrement counter]
>
[>.+<-]

<<<<<<<
.


New Build System

New Build System

This patch provides a new build system that:
- provides support for docker to decrease the time it takes to
  run a build. a local compiler can still be used if desired
- provide better support for other platforms
- provides support for out-of-tree compilation which also
  allows for multiple build trees if desired

Signed-off-by: Rian Quinn <e09fa40acf9eb527a4bd167df46df5cfd127719e@ainfosec.com>

#
# Bareflank Hypervisor
#
# Copyright (C) 2015 Assured Information Security, Inc.
# Author: Rian Quinn        <quinnr@ainfosec.com>
# Author: Brendan Kerrigan  <kerriganb@ainfosec.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

SHELL=/bin/bash

################################################################################
# Color
################################################################################

CS='\033[1;95m'
CE='\033[0m'

################################################################################
# Load Modules
################################################################################

ifeq ($(MODULES),)
	MODULE_FILE=%BUILD_ABS%/module_file
else
	ifneq ($(shell if [[ "$(MODULES)" == "/"* ]]; then echo abs; fi; ),abs)
		MODULE_FILE=$(PWD)/$(MODULES)
	endif
endif

FILTERED_MODULE_FILE=/tmp/module_file

################################################################################
# Subdirs
################################################################################

PARENT_SUBDIRS += bfcrt
PARENT_SUBDIRS += bfunwind
PARENT_SUBDIRS += bfc
PARENT_SUBDIRS += bfcxx
PARENT_SUBDIRS += bfdrivers
PARENT_SUBDIRS += bfelf_loader
PARENT_SUBDIRS += bfm
PARENT_SUBDIRS += bfvmm
PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/src_*/)
PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hypervisor_*/)
PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/src_*/)
PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/hypervisor_*/)

################################################################################
# Common
################################################################################

include %HYPER_ABS%/common/common_subdir.mk

################################################################################
# Custom Targets
################################################################################

.PHONY: linux_load
.PHONY: linux_unload
.PHONY: linux_clean
.PHONY: load
.PHONY: unload
.PHONY: start
.PHONY: stop
.PHONY: dump
.PHONY: status
.PHONY: quick
.PHONY: loop
.PHONY: unittest
.PHONY: astyle
.PHONY: astyle_clean
.PHONY: doxygen
.PHONY: doxygen_clean

linux_load: force
	@cd %HYPER_ABS%/bfdrivers/src/arch/linux; \
	sudo make unload; \
	make clean; \
	make; \
	sudo make load

linux_unload: force
	@cd %HYPER_ABS%/bfdrivers/src/arch/linux; \
	sudo make unload; \
	make clean

linux_clean: linux_unload

load: force
	@%BUILD_ABS%/build_scripts/filter_module_file.sh $(MODULE_FILE) $(FILTERED_MODULE_FILE)
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm load $(FILTERED_MODULE_FILE)

unload: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm unload

start: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm start

stop: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm stop

dump: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm dump

status: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm status

quick: load start

loop: force
	@for n in $(shell seq 1 $(NUM)); do \
		echo -e $(CS)"cycle: $$n"$(CE); \
		$(MAKE) --no-print-directory load; \
		$(MAKE) --no-print-directory start; \
		$(MAKE) --no-print-directory stop; \
		$(MAKE) --no-print-directory unload; \
	done \

unittest: run_tests

astyle:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/linux/run.sh

astyle_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/linux/run.sh clean

doxygen:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/doxygen/linux/run.sh

doxygen_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/doxygen/linux/run.sh clean

#
# Bareflank Hypervisor
#
# Copyright (C) 2015 Assured Information Security, Inc.
# Author: Rian Quinn        <quinnr@ainfosec.com>
# Author: Brendan Kerrigan  <kerriganb@ainfosec.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

SHELL=/bin/bash

################################################################################
# Color
################################################################################

CS='\033[1;95m'
CE='\033[0m'

################################################################################
# Load Modules
################################################################################

ifeq ($(MODULES),)
	MODULE_FILE=%BUILD_ABS%/module_file
else
	ifneq ($(shell if [[ "$(MODULES)" == "/"* ]]; then echo abs; fi; ),abs)
		MODULE_FILE=$(PWD)/$(MODULES)
	endif
endif

FILTERED_MODULE_FILE=/tmp/module_file

################################################################################
# Subdirs
################################################################################

PARENT_SUBDIRS += bfcrt
PARENT_SUBDIRS += bfunwind
PARENT_SUBDIRS += bfc
PARENT_SUBDIRS += bfcxx
PARENT_SUBDIRS += bfdrivers
PARENT_SUBDIRS += bfelf_loader
PARENT_SUBDIRS += bfm
PARENT_SUBDIRS += bfvmm
PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/src_*/)
PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hypervisor_*/)
PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/src_*/)
PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/hypervisor_*/)

################################################################################
# Common
################################################################################

include %HYPER_ABS%/common/common_subdir.mk

################################################################################
# Custom Targets
################################################################################

.PHONY: linux_load
.PHONY: linux_unload
.PHONY: linux_clean
.PHONY: load
.PHONY: unload
.PHONY: start
.PHONY: stop
.PHONY: dump
.PHONY: status
.PHONY: quick
.PHONY: loop
.PHONY: unittest
.PHONY: astyle
.PHONY: astyle_clean
.PHONY: doxygen
.PHONY: doxygen_clean

linux_load: force
	@cd %HYPER_ABS%/bfdrivers/src/arch/linux; \
	sudo make unload; \
	make clean; \
	make; \
	sudo make load

linux_unload: force
	@cd %HYPER_ABS%/bfdrivers/src/arch/linux; \
	sudo make unload; \
	make clean

linux_clean: linux_unload

load: force
	@%BUILD_ABS%/build_scripts/filter_module_file.sh $(MODULE_FILE) $(FILTERED_MODULE_FILE)
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm load $(FILTERED_MODULE_FILE)

unload: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm unload

start: force
	@sync
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm start

stop: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm stop

dump: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm dump

status: force
	@sudo LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm status

quick: load start

loop: force
	@for n in $(shell seq 1 $(NUM)); do \
		echo -e $(CS)"cycle: $$n"$(CE); \
		$(MAKE) --no-print-directory load; \
		$(MAKE) --no-print-directory start; \
		$(MAKE) --no-print-directory stop; \
		$(MAKE) --no-print-directory unload; \
	done \

unittest: run_tests

astyle:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/linux/run.sh

astyle_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/linux/run.sh clean

doxygen:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/doxygen/linux/run.sh

doxygen_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/doxygen/linux/run.sh clean


Switched to 'Hello World!'

Switched to 'Hello World!'


add alphabet program

add alphabet program


Add filling char to bf

Add filling char to bf


Modify rot13.bf to exit on EOF.

Modify rot13.bf to exit on EOF.

,[                         Read first character and start outer character reading loop
    [                       Skip forward if character is 0
        >>++++[>++++++++<-]  Set up divisor (32) for division loop
                               (MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)
        <+<-[                Set up dividend (x minus 1) and enter division loop
            >+>+>-[>>>]      Increase copy and remainder / reduce divisor / Normal case: skip forward
            <[[>+<-]>>+>]    Special case: move remainder back to divisor and increase quotient
            <<<<<-           Decrement dividend
        ]                    End division loop
    ]>>>[-]+                 End skip loop; zero former divisor and reuse space for a flag
    >--[-[<->+++[-]]]<[         Zero that flag unless quotient was 2 or 3; zero quotient; check flag
        ++++++++++++<[       If flag then set up divisor (13) for second division loop
                               (MEMORY LAYOUT: zero copy dividend divisor remainder quotient zero zero)
            >-[>+>>]         Reduce divisor; Normal case: increase remainder
            >[+[<+>-]>+>>]   Special case: increase remainder / move it back to divisor / increase quotient
            <<<<<-           Decrease dividend
        ]                    End division loop
        >>[<+>-]             Add remainder back to divisor to get a useful 13
        >[                   Skip forward if quotient was 0
            -[               Decrement quotient and skip forward if quotient was 1
                -<<[-]>>     Zero quotient and divisor if quotient was 2
            ]<<[<<->>-]>>    Zero divisor and subtract 13 from copy if quotient was 1
        ]<<[<<+>>-]          Zero divisor and add 13 to copy if quotient was 0
    ]                        End outer skip loop (jump to here if ((character minus 1)/32) was not 2 or 3)
    <[-]                     Clear remainder from first division if second division was skipped
    <.[-]                    Output ROT13ed character from copy and clear it
    <,                       Read next character
]                            End character reading loop


Windows Driver Scripts

Windows Driver Scripts

This patch provides the scripts needs to setup cygwin, and
compile the Windows drivers, as well as the cross compilers
for the VMM and BFM.

Signed-off-by: “Rian <1e4902f21d99a8aa0059725a5181749ea9f0425f@gmail.com”>

#
# Bareflank Hypervisor
#
# Copyright (C) 2015 Assured Information Security, Inc.
# Author: Rian Quinn        <quinnr@ainfosec.com>
# Author: Brendan Kerrigan  <kerriganb@ainfosec.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

################################################################################
# Target Information
################################################################################

TARGET_NAME:=misc
TARGET_TYPE:=lib

ifeq ($(shell uname -s), Linux)
    TARGET_COMPILER:=both
else
    TARGET_COMPILER:=cross
endif

################################################################################
# Compiler Flags
################################################################################

CROSS_CCFLAGS+=
CROSS_CXXFLAGS+=
CROSS_ASMFLAGS+=
CROSS_LDFLAGS+=
CROSS_ARFLAGS+=
CROSS_DEFINES+=

################################################################################
# Output
################################################################################

CROSS_OBJDIR+=%BUILD_REL%/.build
CROSS_OUTDIR+=%BUILD_REL%/../bin

################################################################################
# Sources
################################################################################

SOURCES+=misc.cpp
SOURCES+=execute_entry.asm

INCLUDE_PATHS+=./
INCLUDE_PATHS+=%HYPER_ABS%/include/
INCLUDE_PATHS+=%HYPER_ABS%/bfvmm/include/

LIBS+=

LIBRARY_PATHS+=

################################################################################
# Environment Specific
################################################################################

VMM_SOURCES+=
VMM_INCLUDE_PATHS+=
VMM_LIBS+=
VMM_LIBRARY_PATHS+=

WINDOWS_SOURCES+=
WINDOWS_INCLUDE_PATHS+=
WINDOWS_LIBS+=
WINDOWS_LIBRARY_PATHS+=

LINUX_SOURCES+=
LINUX_INCLUDE_PATHS+=
LINUX_LIBS+=
LINUX_LIBRARY_PATHS+=

################################################################################
# Common
################################################################################

include %HYPER_ABS%/common/common_target.mk

#
# Bareflank Hypervisor
#
# Copyright (C) 2015 Assured Information Security, Inc.
# Author: Rian Quinn        <quinnr@ainfosec.com>
# Author: Brendan Kerrigan  <kerriganb@ainfosec.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

################################################################################
# Target Information
################################################################################

TARGET_NAME:=misc
TARGET_TYPE:=lib
TARGET_COMPILER:=cross

################################################################################
# Compiler Flags
################################################################################

CROSS_CCFLAGS+=
CROSS_CXXFLAGS+=
CROSS_ASMFLAGS+=
CROSS_LDFLAGS+=
CROSS_ARFLAGS+=
CROSS_DEFINES+=

################################################################################
# Output
################################################################################

CROSS_OBJDIR+=%BUILD_REL%/.build
CROSS_OUTDIR+=%BUILD_REL%/../bin

################################################################################
# Sources
################################################################################

SOURCES+=misc.cpp
SOURCES+=execute_entry.asm

INCLUDE_PATHS+=./
INCLUDE_PATHS+=%HYPER_ABS%/include/
INCLUDE_PATHS+=%HYPER_ABS%/bfvmm/include/

LIBS+=

LIBRARY_PATHS+=

################################################################################
# Environment Specific
################################################################################

VMM_SOURCES+=
VMM_INCLUDE_PATHS+=
VMM_LIBS+=
VMM_LIBRARY_PATHS+=

WINDOWS_SOURCES+=
WINDOWS_INCLUDE_PATHS+=
WINDOWS_LIBS+=
WINDOWS_LIBRARY_PATHS+=

LINUX_SOURCES+=
LINUX_INCLUDE_PATHS+=
LINUX_LIBS+=
LINUX_LIBRARY_PATHS+=

################################################################################
# Common
################################################################################

include %HYPER_ABS%/common/common_target.mk