updated e340 in Befunge

updated e340 in Befunge


Removed CELLS. Wrong implementation. To be fixed later

Push number 2 on the stack
>>>>+>>+>++<<<


removed unneccessary files

removed unneccessary files


add newline to hello.bf

add newline to hello.bf


cleaned up

cleaned up


nonattribution

nonattribution

(Taken from the wikipedia page for Brainfuck; which doesn't name an author)

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is an "initial comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
++++++++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6


Save the correct hyphy materials

Save the correct hyphy materials

global w;
global t;
global k;

LIKELIHOOD_FUNCTION_OUTPUT = 1;
RANDOM_STARTING_PERTURBATIONS = 1;

/* Include relevant functions */
#include "matrices_fix_k.mdl"; //rate matrices
#include "GY94_Header.ibf";

/* Read in the data */
DataSet	raw_data = ReadDataFile("temp.fasta");

/* Filter the data to find and remove any stop codons*/
DataSetFilter   filt_data = CreateFilter(raw_data,3,"", "","TAA,TAG,TGA");

/* Collect observed frequencies into vectors */
HarvestFrequencies(observedFreq_data,filt_data,3,1,1);

/* Get the codon frequencies from the nucleotide frequency vectors */
codonFreq_data = BuildCodonFrequencies(observedFreq_data);

/* Define the model and tree */
Model MyModel = (GY94, codonFreq_data, 1);
UseModel (USE_NO_MODEL);
UseModel(MyModel);
Tree    Tree01 = DATAFILE_TREE;

/*COMPUTE LIKELIHOODS*/

LikelihoodFunction  LikFn2 = (filt_data, Tree01);

Optimize (paramValues2, LikFn2);
fprintf (stdout, LikFn2);

global w;
global t;
global k;

LIKELIHOOD_FUNCTION_OUTPUT = 1;
RANDOM_STARTING_PERTURBATIONS = 1;

/* Include relevant functions */
#include "matrices.mdl"; //rate matrices
#include "GY94_Header.ibf";

/* Read in the data */
DataSet	raw_data = ReadDataFile("temp.fasta");

/* Filter the data to find and remove any stop codons*/
DataSetFilter   filt_data = CreateFilter(raw_data,3,"", "","TAA,TAG,TGA");

/* Collect observed frequencies into vectors */
HarvestFrequencies(observedFreq_data,filt_data,3,1,1);

/* Get the codon frequencies from the nucleotide frequency vectors */
codonFreq_data = BuildCodonFrequencies(observedFreq_data);

/* Define the model and tree */
Model MyModel = (GY94, codonFreq_data, 1);
UseModel (USE_NO_MODEL);
UseModel(MyModel);
Tree    Tree01 = DATAFILE_TREE;

/*COMPUTE LIKELIHOODS*/

LikelihoodFunction  LikFn2 = (filt_data, Tree01);

Optimize (paramValues2, LikFn2);
fprintf (stdout, LikFn2);


Increasing parallelism of performance fastest since we now have 2 machines with 16 processors x 2 threads

# fastest.bf
# Optimised settings for rbuild.
# GBB 03/2013   <grb@skogoglandskap.no>

# Note: these settings are only slightly faster than 'performance_fast.bf'
# The temporary files produced along the way are much bigger - up to 10x bigger.

# Import performance_fast.bf, to be modified.
. $BUILDFILE_DIR/standard/performance_fast.bf

# Maximum number of threads to run with Gnu Parallel. 8-12 is fast. 1-2 is polite.
MAX_THREADS=16

# Compressor: DEFLATE, LZW, or PACKBITS
WORKING_COMPRESSOR=PACKBITS
FINAL_COMPRESSOR=DEFLATE

# fastest.bf
# Optimised settings for rbuild.
# GBB 03/2013   <grb@skogoglandskap.no>

# Note: these settings are only slightly faster than 'performance_fast.bf'
# The temporary files produced along the way are much bigger - up to 10x bigger.

# Import performance_fast.bf, to be modified.
. $BUILDFILE_DIR/standard/performance_fast.bf

# Maximum number of threads to run with Gnu Parallel. 8-12 is fast. 1-2 is polite.
MAX_THREADS=12

# Compressor: DEFLATE, LZW, or PACKBITS
WORKING_COMPRESSOR=PACKBITS
FINAL_COMPRESSOR=DEFLATE


Reducing bevel size because it is too big on e.g. dyrkbarjord by default

# standard_polygonize.bf
# Normal polygonization settings with douglas-peuker smoothing.
# GBB 03/2013   <grb@skogoglandskap.no>

# Standard flags

	POLYGONIZE_FLAGS="-classify -out-cs en -split-polys -dp-toler 0 -bevel-size 0.01 -ogr-fmt 'ESRI Shapefile' -ogr-out "

	#### Important flags.
	# -classify -> identify each area, not just a single polygon of all areas with data.
	# -out-cs en -> easting/northing output. long/lat & pixel index are also available.
	# -ndv: no data value. avoids a large nodata polygon.
	# -split-polys -> avoid complex polygons (multipolygons).
	# -dp-toler val -> Tolerance for polygon simplification (in pixels, default is 2.0). Setting to zero makes borders exact.
	# -min-ring-area (pixel area), -erosion - used to remove small or thin areas.

	# -geo_srs included in build_functions call automatically, assigns output coordinate system. equivalent to a_srs in ogr.
	# -ogr-out (or similar)should be put at the end of the options.
	# Note that the nodata area will be output as a polygon too. This is an unavoidable effect of -classify.
	# It is also possible to generate polygons directly into postgresql via OGR.
        # Very good idea to use '' for ogr-fmt variable

	# ESRI Shapefile output

	POLYGONIZE_SUFFIX="shp"

        # Should polygons be tiled? (using the map raster tiling settings)
        # Beware! If you're working on a large map you may get some large
        # polygons that take ages to polygonise and can't be rendered in qgis

        OUTPUT_AS_TILES=YES

# standard_polygonize.bf
# Normal polygonization settings with douglas-peuker smoothing.
# GBB 03/2013   <grb@skogoglandskap.no>

# Standard flags

	POLYGONIZE_FLAGS="-classify -out-cs en -split-polys -dp-toler 0 -ogr-fmt 'ESRI Shapefile' -ogr-out "

	#### Important flags.
	# -classify -> identify each area, not just a single polygon of all areas with data.
	# -out-cs en -> easting/northing output. long/lat & pixel index are also available.
	# -ndv: no data value. avoids a large nodata polygon.
	# -split-polys -> avoid complex polygons (multipolygons).
	# -dp-toler val -> Tolerance for polygon simplification (in pixels, default is 2.0). Setting to zero makes borders exact.
	# -min-ring-area (pixel area), -erosion - used to remove small or thin areas.

	# -geo_srs included in build_functions call automatically, assigns output coordinate system. equivalent to a_srs in ogr.
	# -ogr-out (or similar)should be put at the end of the options.
	# Note that the nodata area will be output as a polygon too. This is an unavoidable effect of -classify.
	# It is also possible to generate polygons directly into postgresql via OGR.
        # Very good idea to use '' for ogr-fmt variable

	# ESRI Shapefile output

	POLYGONIZE_SUFFIX="shp"

        # Should polygons be tiled? (using the map raster tiling settings)
        # Beware! If you're working on a large map you may get some large
        # polygons that take ages to polygonise and can't be rendered in qgis

        OUTPUT_AS_TILES=YES


Added Hello world example from helloworld.org

The MIT License (MIT)

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


Update hello.bf

Update hello.bf

[hello.bf: Print "Hello World"]

[Loop body explanation:]
[This loop initializes the values for data address 1 through 4 to values _close_ to what we want]
[Execute this loop 10 times: ++++++++++]
[Move to data index 1 and increment by  7: >+++++++]
[Move to data index 2 and increment by 10: >++++++++++]
[Move to data index 3 and increment by  3: >+++]
[Move to data index 4 and increment by  1: >+]
[Move to data index 0 and decrement by  1: <<<<-]

[At this point, the data will be initialized to the following]
[  0 70 100 30 10] [decimal values]
[NUL  F   d RS \n] [characters]
[Not quite what we want, but using a loop kept the initializer code short]

[Now let's fine-tune the values and print them]
[Task        Code                    Data (characters)]
[Print 'H':  >++.]                   [NUL H d RS  \n]
[Print 'e':  >+.]                    [NUL H e RS  \n]
[Print 'l':  +++++++.]               [NUL H l RS  \n]
[Print 'l':  .]                      [NUL H l RS  \n]
[Print 'o':  +++.]                   [NUL H o RS  \n]
[Print ' ':  >++.]                   [NUL H o ' ' \n]
[Print 'W':  <<+++++++++++++++.]     [NUL W o ' ' \n]
[Print 'o':  >.]                     [NUL W o ' ' \n]
[Print 'r':  +++.]                   [NUL W r ' ' \n]
[Print 'l':  ------.]                [NUL W l ' ' \n]
[Print 'd':  --------.]              [NUL W d ' ' \n]
[Print '!':  >+.]                    [NUL W d !   \n]
[Print '\n': >.]                     [NUL W d !   \n]

[Now that you've read the explanation, let's run it!]
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.


Fixed quoted size in thread state comment

--
-- 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)
--

-- Default base size: uint32_t
base 32

block null_cap {
    padding 32

    padding 28
    field capType 4
}

block untyped_cap {
    field capFreeIndex 27
    field capBlockSize 5

    field_high capPtr 28
    field capType     4
}

block endpoint_cap(capEPBadge, capCanGrant, capCanSend, capCanReceive,
                   capEPPtr, capType) {
    field_high capEPPtr 28
    padding 1
    field capCanGrant 1
    field capCanReceive 1
    field capCanSend 1

    field capEPBadge 28
    field capType 4
}

block async_endpoint_cap {
    field capAEPBadge 28
    padding 2
    field capAEPCanReceive 1
    field capAEPCanSend 1

    field_high capAEPPtr 28
    field capType 4
}

block reply_cap(capReplyMaster, capTCBPtr, capType) {
    padding 32

    field_high capTCBPtr 27
    field capReplyMaster 1
    field capType 4
}

-- The user-visible format of the data word is defined by cnode_capdata, below.
block cnode_cap(capCNodeRadix, capCNodeGuardSize, capCNodeGuard,
                capCNodePtr, capType) {
    padding 4
    field capCNodeGuardSize 5
    field capCNodeRadix 5
    field capCNodeGuard 18

    field_high capCNodePtr 27
    padding 1
    field capType 4
}

block cnode_capdata {
    padding 6
    field guard 18
    field guardSize 5
    padding 3
}

block thread_cap {
    padding              32

    field_high capTCBPtr 28
    field capType         4
}

block irq_control_cap {
    padding       32

    padding       24
    field capType  8
}

block irq_handler_cap {
    padding       24
    field capIRQ   8

    padding       24
    field capType  8
}

block zombie_cap {
    field capZombieID     32

    padding               18
    field capZombieType   6
    field capType         8
}

block domain_cap {
    padding 32

    padding 24
    field capType 8
}

---- Arch-independent object types

-- Endpoint: size = 16 bytes
block endpoint {
    padding 64

    field_high epQueue_head 28
    padding 4

    field_high epQueue_tail 28
    padding 2
    field state 2
}

-- Async endpoint: size = 16 bytes
block async_endpoint {
    field aepData 32

    field aepMsgIdentifier 32

    field_high aepQueue_head 28
    padding 4

    field_high aepQueue_tail 28
    padding 2
    field state 2
}

-- Mapping database (MDB) node: size = 8 bytes
block mdb_node {
    field_high mdbNext 29
    padding 1
    field mdbRevocable 1
    field mdbFirstBadged 1

    field_high mdbPrev 29
    padding 3
}

-- Thread state data
--
-- tsType
-- * Running
-- * Restart
-- * Inactive
-- * BlockedOnReceive
--   - DiminishCaps
--   - Endpoint
-- * BlockedOnSend
--   - Endpoint
--   - CanGrant
--   - IsCall
--   - IPCBadge
--   - Fault
--     - faultType
--     * CapFault
--       - Address
--       - InReceivePhase
--       - LookupFailure
--         - lufType
--         * InvalidRoot
--         * MissingCapability
--           - BitsLeft
--         * DepthMismatch
--           - BitsFound
--           - BitsLeft
--         * GuardMismatch
--           - GuardFound
--           - BitsLeft
--           - GuardSize
--     * VMFault
--       - Address
--       - FSR
--       - FaultType
--     * UnknownSyscall
--       - Number
--     * UserException
--       - Number
--       - Code
-- * BlockedOnReply
-- * BlockedOnFault
--   - Fault
-- * BlockedOnAsyncEvent
--   - AEP
-- * Idle

-- Lookup fault: size = 8 bytes
block invalid_root {
    padding 62
    field lufType 2
}

block missing_capability {
    padding 56
    field bitsLeft 6
    field lufType 2
}

block depth_mismatch {
    padding 50
    field bitsFound 6
    field bitsLeft 6
    field lufType 2
}

block guard_mismatch {
    field guardFound 32
    padding 18
    field bitsLeft 6
    field bitsFound 6
    field lufType 2
}

tagged_union lookup_fault lufType {
    tag invalid_root 0
    tag missing_capability 1
    tag depth_mismatch 2
    tag guard_mismatch 3
}

-- Fault: size = 8 bytes
block null_fault {
    padding 61
    field faultType 3
}

block cap_fault {
    field address 32
    field inReceivePhase 1
    padding 28
    field faultType 3
}

block unknown_syscall {
    field syscallNumber 32
    padding 29
    field faultType 3
}

block user_exception {
    field number 32
    field code 29
    field faultType 3
}

-- Thread state: size = 12 bytes
block thread_state(blockingIPCBadge, blockingIPCCanGrant, blockingIPCIsCall,
                   tcbQueued, blockingIPCDiminishCaps, blockingIPCEndpoint,
                   tsType) {
    field blockingIPCBadge 28
    field blockingIPCCanGrant 1
    field blockingIPCIsCall 1
    padding 1
    field blockingIPCDiminishCaps 1

    -- this is fastpath-specific. it is useful to be able to write
    -- tsType and blockingIPCDiminishCaps without changing tcbQueued
    padding 31
    field tcbQueued 1

    field_high blockingIPCEndpoint 28
    field tsType 4
}

--
-- 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)
--

-- Default base size: uint32_t
base 32

block null_cap {
    padding 32

    padding 28
    field capType 4
}

block untyped_cap {
    field capFreeIndex 27
    field capBlockSize 5

    field_high capPtr 28
    field capType     4
}

block endpoint_cap(capEPBadge, capCanGrant, capCanSend, capCanReceive,
                   capEPPtr, capType) {
    field_high capEPPtr 28
    padding 1
    field capCanGrant 1
    field capCanReceive 1
    field capCanSend 1

    field capEPBadge 28
    field capType 4
}

block async_endpoint_cap {
    field capAEPBadge 28
    padding 2
    field capAEPCanReceive 1
    field capAEPCanSend 1

    field_high capAEPPtr 28
    field capType 4
}

block reply_cap(capReplyMaster, capTCBPtr, capType) {
    padding 32

    field_high capTCBPtr 27
    field capReplyMaster 1
    field capType 4
}

-- The user-visible format of the data word is defined by cnode_capdata, below.
block cnode_cap(capCNodeRadix, capCNodeGuardSize, capCNodeGuard,
                capCNodePtr, capType) {
    padding 4
    field capCNodeGuardSize 5
    field capCNodeRadix 5
    field capCNodeGuard 18

    field_high capCNodePtr 27
    padding 1
    field capType 4
}

block cnode_capdata {
    padding 6
    field guard 18
    field guardSize 5
    padding 3
}

block thread_cap {
    padding              32

    field_high capTCBPtr 28
    field capType         4
}

block irq_control_cap {
    padding       32

    padding       24
    field capType  8
}

block irq_handler_cap {
    padding       24
    field capIRQ   8

    padding       24
    field capType  8
}

block zombie_cap {
    field capZombieID     32

    padding               18
    field capZombieType   6
    field capType         8
}

block domain_cap {
    padding 32

    padding 24
    field capType 8
}

---- Arch-independent object types

-- Endpoint: size = 16 bytes
block endpoint {
    padding 64

    field_high epQueue_head 28
    padding 4

    field_high epQueue_tail 28
    padding 2
    field state 2
}

-- Async endpoint: size = 16 bytes
block async_endpoint {
    field aepData 32

    field aepMsgIdentifier 32

    field_high aepQueue_head 28
    padding 4

    field_high aepQueue_tail 28
    padding 2
    field state 2
}

-- Mapping database (MDB) node: size = 8 bytes
block mdb_node {
    field_high mdbNext 29
    padding 1
    field mdbRevocable 1
    field mdbFirstBadged 1

    field_high mdbPrev 29
    padding 3
}

-- Thread state data
--
-- tsType
-- * Running
-- * Restart
-- * Inactive
-- * BlockedOnReceive
--   - DiminishCaps
--   - Endpoint
-- * BlockedOnSend
--   - Endpoint
--   - CanGrant
--   - IsCall
--   - IPCBadge
--   - Fault
--     - faultType
--     * CapFault
--       - Address
--       - InReceivePhase
--       - LookupFailure
--         - lufType
--         * InvalidRoot
--         * MissingCapability
--           - BitsLeft
--         * DepthMismatch
--           - BitsFound
--           - BitsLeft
--         * GuardMismatch
--           - GuardFound
--           - BitsLeft
--           - GuardSize
--     * VMFault
--       - Address
--       - FSR
--       - FaultType
--     * UnknownSyscall
--       - Number
--     * UserException
--       - Number
--       - Code
-- * BlockedOnReply
-- * BlockedOnFault
--   - Fault
-- * BlockedOnAsyncEvent
--   - AEP
-- * Idle

-- Lookup fault: size = 8 bytes
block invalid_root {
    padding 62
    field lufType 2
}

block missing_capability {
    padding 56
    field bitsLeft 6
    field lufType 2
}

block depth_mismatch {
    padding 50
    field bitsFound 6
    field bitsLeft 6
    field lufType 2
}

block guard_mismatch {
    field guardFound 32
    padding 18
    field bitsLeft 6
    field bitsFound 6
    field lufType 2
}

tagged_union lookup_fault lufType {
    tag invalid_root 0
    tag missing_capability 1
    tag depth_mismatch 2
    tag guard_mismatch 3
}

-- Fault: size = 8 bytes
block null_fault {
    padding 61
    field faultType 3
}

block cap_fault {
    field address 32
    field inReceivePhase 1
    padding 28
    field faultType 3
}

block unknown_syscall {
    field syscallNumber 32
    padding 29
    field faultType 3
}

block user_exception {
    field number 32
    field code 29
    field faultType 3
}

-- Thread state: size = 8 bytes
block thread_state(blockingIPCBadge, blockingIPCCanGrant, blockingIPCIsCall,
                   tcbQueued, blockingIPCDiminishCaps, blockingIPCEndpoint,
                   tsType) {
    field blockingIPCBadge 28
    field blockingIPCCanGrant 1
    field blockingIPCIsCall 1
    padding 1
    field blockingIPCDiminishCaps 1

    -- this is fastpath-specific. it is useful to be able to write
    -- tsType and blockingIPCDiminishCaps without changing tcbQueued
    padding 31
    field tcbQueued 1

    field_high blockingIPCEndpoint 28
    field tsType 4
}


Fixed for possible commenting bug

Fixed for possible commenting bug


got the chars needed in cells

got the chars needed in cells

I hate that I love that I hate it
http://codegolf.stackexchange.com/questions/91797/hate-love-conundrum

CHAR DEC CELL

I 73 2
++++++++++[>+++++++<-]>+++.

space 20 4
>++++++[>++++++<-]>----.

get input
>>,

put input as number in cell 6
<----------[>-----<-]>-


Update HelloWorld.bf

Update HelloWorld.bf

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is a "comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
+++++ +++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6


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

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


read.bf

read.bf


Compialtion Bug

Compialtion Bug

Fixes an issue where extensions were being compiled more than
once

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

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

################################################################################
# Sudo
################################################################################

ifeq ($(shell uname -s), Linux)
	SUDO:=sudo
else
	SUDO:=
endif

################################################################################
# CPUID / VCPUID
################################################################################

ifeq ($(CPUID),)
	CPUID=0
endif

ifeq ($(VCPUID),)
	VCPUID=0
endif

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

ifneq ($(APPVEYOR), true)
	PARENT_SUBDIRS += bfc
	PARENT_SUBDIRS += bfcxx
	PARENT_SUBDIRS += bfcrt
	PARENT_SUBDIRS += bfunwind
endif

PARENT_SUBDIRS += bfm

ifneq ($(APPVEYOR), true)
	PARENT_SUBDIRS += bfdrivers
	PARENT_SUBDIRS += bfelf_loader
	PARENT_SUBDIRS += bfvmm
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/extended_apis/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hyperkernel/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/src_*/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hypervisor_*/)

	ifneq (%HYPER_ABS%, %BUILD_ABS%)
		PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/src_*/)
		PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/hypervisor_*/)
	endif
endif

include extensions.mk

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

include %HYPER_ABS%/common/common_subdir.mk

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

.PHONY: linux_build
.PHONY: linux_load
.PHONY: linux_unload
.PHONY: windows_build
.PHONY: windows_load
.PHONY: windows_unload
.PHONY: driver_build
.PHONY: driver_load
.PHONY: driver_unload
.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
.PHONY: test
.PHONY: tidy

windows_build: force
	@%BUILD_ABS%/build_scripts/build_driver.sh

windows_load: force
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

windows_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

linux_build: force
	@%BUILD_ABS%/build_scripts/build_driver.sh

linux_load: force
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

linux_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

driver_build:
	@%BUILD_ABS%/build_scripts/build_driver.sh

driver_load:
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

driver_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

load: force
	@$(SUDO) rm -Rf $(FILTERED_MODULE_FILE)
	@%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)
	@$(SUDO) rm -Rf $(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 --vcpuid $(VCPUID)

status: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm status

vmcall: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm vmcall --cpuid $(CPUID) ${ARGS}

help: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm --help

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
test: run_tests

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

astyle_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/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

tidy:
	@cd %HYPER_ABS%; \
	%BUILD_ABS%/build_scripts/verify_source.sh

#
# 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

################################################################################
# Sudo
################################################################################

ifeq ($(shell uname -s), Linux)
	SUDO:=sudo
else
	SUDO:=
endif

################################################################################
# CPUID / VCPUID
################################################################################

ifeq ($(CPUID),)
	CPUID=0
endif

ifeq ($(VCPUID),)
	VCPUID=0
endif

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

ifneq ($(APPVEYOR), true)
	PARENT_SUBDIRS += bfc
	PARENT_SUBDIRS += bfcxx
	PARENT_SUBDIRS += bfcrt
	PARENT_SUBDIRS += bfunwind
endif

PARENT_SUBDIRS += bfm

ifneq ($(APPVEYOR), true)
	PARENT_SUBDIRS += bfdrivers
	PARENT_SUBDIRS += bfelf_loader
	PARENT_SUBDIRS += bfvmm
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/extended_apis/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hyperkernel/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/src_*/)
	PARENT_SUBDIRS += $(wildcard %HYPER_ABS%/hypervisor_*/)
	PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/extended_apis/)
	PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/hyperkernel/)
	PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/src_*/)
	PARENT_SUBDIRS += $(wildcard %BUILD_ABS%/makefiles/hypervisor_*/)
endif

include extensions.mk

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

include %HYPER_ABS%/common/common_subdir.mk

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

.PHONY: linux_build
.PHONY: linux_load
.PHONY: linux_unload
.PHONY: windows_build
.PHONY: windows_load
.PHONY: windows_unload
.PHONY: driver_build
.PHONY: driver_load
.PHONY: driver_unload
.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
.PHONY: test
.PHONY: tidy

windows_build: force
	@%BUILD_ABS%/build_scripts/build_driver.sh

windows_load: force
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

windows_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

linux_build: force
	@%BUILD_ABS%/build_scripts/build_driver.sh

linux_load: force
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

linux_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

driver_build:
	@%BUILD_ABS%/build_scripts/build_driver.sh

driver_load:
	@%BUILD_ABS%/build_scripts/build_driver.sh
	@%BUILD_ABS%/build_scripts/load_driver.sh

driver_unload: force
	@%BUILD_ABS%/build_scripts/clean_driver.sh

load: force
	@$(SUDO) rm -Rf $(FILTERED_MODULE_FILE)
	@%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)
	@$(SUDO) rm -Rf $(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 --vcpuid $(VCPUID)

status: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm status

vmcall: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm vmcall --cpuid $(CPUID) ${ARGS}

help: force
	@$(SUDO) LD_LIBRARY_PATH=%BUILD_ABS%/makefiles/bfm/bin/native/ %BUILD_ABS%/makefiles/bfm/bin/native/bfm --help

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
test: run_tests

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

astyle_clean:
	@cd %HYPER_ABS%; \
	%HYPER_ABS%/tools/astyle/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

tidy:
	@cd %HYPER_ABS%; \
	%BUILD_ABS%/build_scripts/verify_source.sh


remove

remove


Removed generated Brainfuck minimal example.


fix test.bf

fix test.bf

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


Isolation Complete

Isolation Complete

This patch set adds the remaining code needed to isolate the
hypervisor from the host OS. Specifically, this provides
the hypervisor with it's own set of page tables.

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

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

#
# 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


Implemented clean up code to restore to original state

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
< [-<<<[<<]>>>>>+<[>>]<]
clean up
<[-]<<[-<<]>>+>>+<<


fix hello world program

fix hello world program


Cleaned up code

Cleaned up code


Interpreter wanted input because of two ","...


while true loop example

while true loop example


Removed duplicate mandelbrot

Removed duplicate mandelbrot


x64: Update IO port cap type to match ia32

--
-- Copyright 2016, Data61
-- Commonwealth Scientific and Industrial Research Organisation (CSIRO)
-- ABN 41 687 119 230.
--
-- 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(D61_GPL)
--

#include <config.h>

---- Default base size: uint64_t
base 64(48,1)

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

---- x86-64 specific cap types

block frame_cap {
    -- The ASID doubles as the PCI bus/dev/fun when used in an IOMMU context
    -- so it is 16 instead of 12
    field       capFMappedASID      16
    field_high  capFBasePtr         48

    field       capType             5
    field       capFSize            2
    field       capFMapType         2
    field_high  capFMappedAddress   48
    field       capFVMRights        2
    field       capFIsDevice        1
    padding                         4
}

-- Second-level page table
block page_table_cap {
    padding                         4
    field       capPTMappedASID     12
    field_high  capPTBasePtr        48

    field       capType             5
    padding                         10
    field       capPTIsMapped       1
    field_high  capPTMappedAddress  27

    padding                         21
}

-- First-level page table (page directory)
block page_directory_cap {
    padding                         4
    field       capPDMappedASID     12
    field_high  capPDBasePtr        48

    field       capType             5
    padding                         10
    field       capPDIsMapped       1
    field_high  capPDMappedAddress  18

    padding                         30
}

block pdpt_cap {
    padding                          4
    field       capPDPTMappedASID    12
    field_high  capPDPTBasePtr       48

    field       capType              5
    field       capPDPTIsMapped      1
    field_high  capPDPTMappedAddress 9
    padding                          49
}

block pml4_cap {
    padding                         4
    field       capPML4MappedASID   12
    field_high  capPML4BasePtr      48

    field       capType             5
    field       capPML4IsMapped     1
    padding                         58
}

-- Cap to the table of 2^6 ASID pools
block asid_control_cap {
    padding 64

    field   capType     5
    padding             59
}

-- Cap to a pool of 2^9 ASIDs
block asid_pool_cap {
    padding 64

    field       capType         5
    field       capASIDBase     12
    padding                     11
    field_high  capASIDPool     36
}

-- IO Port Cap
block io_port_cap {
    padding 64
    field   capType            5
    padding 3
    field   capIOPortFirstPort 16
    field   capIOPortLastPort  16

    padding                    8
    field   capIOPortVPID      16
}

block io_port_capdata {
    padding 32
    field   firstPort          16
    field   lastPort           16
}

-- IO Space Cap
block io_space_cap {
    padding 64
    field       capType         5
    field       capDomainID     16
    field       capPCIDevice    16

    padding                     27
}

block io_space_capdata {
    padding 32
    field domainID              16
    field PCIDevice             16
}

-- IO Page Table Cap
block io_page_table_cap (capType, capIOPTIsMapped, capIOPTLevel, capIOPTMappedAddress, capIOPTIOASID, capIOPTBasePtr) {
    -- IOASID is actually a PCI bus/dev/fun and so is 16
    field       capIOPTIOASID           16
    field_high capIOPTBasePtr 48

    field       capType                 5
    padding                             6
    field       capIOPTIsMapped         1
    field       capIOPTLevel            4
    field_high  capIOPTMappedAddress    48
}

-- NB: odd numbers are arch caps (see isArchCap())
tagged_union cap capType {
    -- 5-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
    tag irq_control_cap     14
    tag irq_handler_cap     16
    tag zombie_cap          18
    tag domain_cap	        20

    -- 5-bit tag arch caps
    tag frame_cap           1
    tag page_table_cap      3
    tag page_directory_cap  5
    tag pdpt_cap            7
    tag pml4_cap            9
    tag asid_control_cap    11
    tag asid_pool_cap       13
    tag io_space_cap        15
    tag io_page_table_cap   17
    tag io_port_cap         19
}

---- Arch-independent object types

block vm_fault {
    field     address           64

    padding                     32
    field     FSR               5
    padding                     7
    field     instructionFault  1
    padding                     16
    field     faultType         3
}

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_HARDWARE_DEBUG_API
    tag debug_exception 5
#endif
}

-- VM attributes

block vm_attributes {
    padding         61
    field x86PATBit 1
    field x86PCDBit 1
    field x86PWTBit 1
}

---- x86-64 specific object types

-- GDT entries (Segment Desciptors)

block gdt_null {
    padding                         19
    padding                         1
    field       seg_type            4
    padding                         40
}

block gdt_code {
    field       base_high           8
    field       granularity         1
    field       operation_size      1
    field       long_mode           1
    field       avl                 1
    field       seg_limit_high      4
    field       present             1
    field       dpl                 2
    field       always_1            1
    field       seg_type            4
    field       base_mid            8
    field       base_low            16
    field       seg_limit_low       16
}

block gdt_data {
    field       base_high           8
    field       granularity         1
    field       operation_size      1
    padding                         1
    field       avl                 1
    field       seg_limit_high      4
    field       present             1
    field       dpl                 2
    field       always_1            1
    field       seg_type            4
    field       base_mid            8
    field       base_low            16
    field       seg_limit_low       16
}

block gdt_tss {
    padding                         32
    field       base_63_32          32

    field       base_31_24          8
    field       granularity         1
    padding                         2
    field       avl                 1
    field       limit_high          4
    field       present             1
    field       dpl                 2
    padding                         1
    field       desc_type           4
    field       base_23_16          8
    field       base_15_0           16
    field       limit_low           16
}

tagged_union gdt_entry seg_type {
    tag gdt_null    0
    tag gdt_data    7
    tag gdt_code    11
}

-- IDT entries (Gate Desciptors)

block task_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       tss_seg_selector    16
    field       offset_15_0         16
}

block interrupt_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       seg_selector        16
    field       offset_15_0         16
}

block trap_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       seg_selector        16
    field       offset_15_0         16
}

tagged_union idt_entry type {
    tag interrupt_gate  14
    tag trap_gate       15
}

-- Task State Segment (TSS)

block tss {
    field       io_map_base               16
    padding                               16
    padding                               32
    padding                               32
    field ist7_u                          32
    field ist7_l                          32
    field ist6_u                          32
    field ist6_l                          32
    field ist5_u                          32
    field ist5_l                          32
    field ist4_u                          32
    field ist4_l                          32
    field ist3_u                          32
    field ist3_l                          32
    field ist2_u                          32
    field ist2_l                          32
    field ist1_u                          32
    field ist1_l                          32
    padding                               32
    padding                               32
    field rsp2_u                          32
    field rsp2_l                          32
    field rsp1_u                          32
    field rsp1_l                          32
    field rsp0_u                          32
    field rsp0_l                          32
    padding                               32
}

-- PML4, PDPE, PDs and PTs, assuming 51-bit physical address
base 64(51,0)

block pml4e {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pdpt_base_address   39
    padding                         4
    padding                         1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pdpte_1g {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   21
    padding                         17
    field       pat                 1
    padding                         3
    field       global              1
    field       page_size           1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pdpte_pd {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pd_base_address     39
    padding                         4
    field       page_size           1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

tagged_union pdpte page_size {
    tag         pdpte_1g            1
    tag         pdpte_pd            0
}

block pde_large {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   30
    padding                         8
    field       pat                 1
    padding                         3
    field       global              1
    field       page_size           1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pde_small {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pt_base_address     39
    padding                         4
    field       page_size           1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

tagged_union pde page_size {
    tag pde_small 0
    tag pde_large 1
}

block pte {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   39
    padding                         3
    field       global              1
    field       pat                 1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block cr3 {
    padding                         13
    field_high  pml4_base_address   39
    field       pcid                12
}

--
-- Copyright 2016, Data61
-- Commonwealth Scientific and Industrial Research Organisation (CSIRO)
-- ABN 41 687 119 230.
--
-- 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(D61_GPL)
--

#include <config.h>

---- Default base size: uint64_t
base 64(48,1)

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

---- x86-64 specific cap types

block frame_cap {
    -- The ASID doubles as the PCI bus/dev/fun when used in an IOMMU context
    -- so it is 16 instead of 12
    field       capFMappedASID      16
    field_high  capFBasePtr         48

    field       capType             5
    field       capFSize            2
    field       capFMapType         2
    field_high  capFMappedAddress   48
    field       capFVMRights        2
    field       capFIsDevice        1
    padding                         4
}

-- Second-level page table
block page_table_cap {
    padding                         4
    field       capPTMappedASID     12
    field_high  capPTBasePtr        48

    field       capType             5
    padding                         10
    field       capPTIsMapped       1
    field_high  capPTMappedAddress  27

    padding                         21
}

-- First-level page table (page directory)
block page_directory_cap {
    padding                         4
    field       capPDMappedASID     12
    field_high  capPDBasePtr        48

    field       capType             5
    padding                         10
    field       capPDIsMapped       1
    field_high  capPDMappedAddress  18

    padding                         30
}

block pdpt_cap {
    padding                          4
    field       capPDPTMappedASID    12
    field_high  capPDPTBasePtr       48

    field       capType              5
    field       capPDPTIsMapped      1
    field_high  capPDPTMappedAddress 9
    padding                          49
}

block pml4_cap {
    padding                         4
    field       capPML4MappedASID   12
    field_high  capPML4BasePtr      48

    field       capType             5
    field       capPML4IsMapped     1
    padding                         58
}

-- Cap to the table of 2^6 ASID pools
block asid_control_cap {
    padding 64

    field   capType     5
    padding             59
}

-- Cap to a pool of 2^9 ASIDs
block asid_pool_cap {
    padding 64

    field       capType         5
    field       capASIDBase     12
    padding                     11
    field_high  capASIDPool     36
}

-- IO Port Cap
block io_port_cap {
    padding 64
    field   capType            5
    padding 3
    field   capIOPortFirstPort 16
    field   capIOPortLastPort  16

    padding                    24
}

block io_port_capdata {
    padding 32
    field   firstPort          16
    field   lastPort           16
}

-- IO Space Cap
block io_space_cap {
    padding 64
    field       capType         5
    field       capDomainID     16
    field       capPCIDevice    16

    padding                     27
}

block io_space_capdata {
    padding 32
    field domainID              16
    field PCIDevice             16
}

-- IO Page Table Cap
block io_page_table_cap (capType, capIOPTIsMapped, capIOPTLevel, capIOPTMappedAddress, capIOPTIOASID, capIOPTBasePtr) {
    -- IOASID is actually a PCI bus/dev/fun and so is 16
    field       capIOPTIOASID           16
    field_high capIOPTBasePtr 48

    field       capType                 5
    padding                             6
    field       capIOPTIsMapped         1
    field       capIOPTLevel            4
    field_high  capIOPTMappedAddress    48
}

-- NB: odd numbers are arch caps (see isArchCap())
tagged_union cap capType {
    -- 5-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
    tag irq_control_cap     14
    tag irq_handler_cap     16
    tag zombie_cap          18
    tag domain_cap	        20

    -- 5-bit tag arch caps
    tag frame_cap           1
    tag page_table_cap      3
    tag page_directory_cap  5
    tag pdpt_cap            7
    tag pml4_cap            9
    tag asid_control_cap    11
    tag asid_pool_cap       13
    tag io_space_cap        15
    tag io_page_table_cap   17
    tag io_port_cap         19
}

---- Arch-independent object types

block vm_fault {
    field     address           64

    padding                     32
    field     FSR               5
    padding                     7
    field     instructionFault  1
    padding                     16
    field     faultType         3
}

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_HARDWARE_DEBUG_API
    tag debug_exception 5
#endif
}

-- VM attributes

block vm_attributes {
    padding         61
    field x86PATBit 1
    field x86PCDBit 1
    field x86PWTBit 1
}

---- x86-64 specific object types

-- GDT entries (Segment Desciptors)

block gdt_null {
    padding                         19
    padding                         1
    field       seg_type            4
    padding                         40
}

block gdt_code {
    field       base_high           8
    field       granularity         1
    field       operation_size      1
    field       long_mode           1
    field       avl                 1
    field       seg_limit_high      4
    field       present             1
    field       dpl                 2
    field       always_1            1
    field       seg_type            4
    field       base_mid            8
    field       base_low            16
    field       seg_limit_low       16
}

block gdt_data {
    field       base_high           8
    field       granularity         1
    field       operation_size      1
    padding                         1
    field       avl                 1
    field       seg_limit_high      4
    field       present             1
    field       dpl                 2
    field       always_1            1
    field       seg_type            4
    field       base_mid            8
    field       base_low            16
    field       seg_limit_low       16
}

block gdt_tss {
    padding                         32
    field       base_63_32          32

    field       base_31_24          8
    field       granularity         1
    padding                         2
    field       avl                 1
    field       limit_high          4
    field       present             1
    field       dpl                 2
    padding                         1
    field       desc_type           4
    field       base_23_16          8
    field       base_15_0           16
    field       limit_low           16
}

tagged_union gdt_entry seg_type {
    tag gdt_null    0
    tag gdt_data    7
    tag gdt_code    11
}

-- IDT entries (Gate Desciptors)

block task_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       tss_seg_selector    16
    field       offset_15_0         16
}

block interrupt_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       seg_selector        16
    field       offset_15_0         16
}

block trap_gate {
    padding                         32
    field       offset_63_32        32

    field       offset_31_16        16
    field       present             1
    field       dpl                 2
    padding                         1
    field       type                4
    padding                         5
    field       ist                 3
    field       seg_selector        16
    field       offset_15_0         16
}

tagged_union idt_entry type {
    tag interrupt_gate  14
    tag trap_gate       15
}

-- Task State Segment (TSS)

block tss {
    field       io_map_base               16
    padding                               16
    padding                               32
    padding                               32
    field ist7_u                          32
    field ist7_l                          32
    field ist6_u                          32
    field ist6_l                          32
    field ist5_u                          32
    field ist5_l                          32
    field ist4_u                          32
    field ist4_l                          32
    field ist3_u                          32
    field ist3_l                          32
    field ist2_u                          32
    field ist2_l                          32
    field ist1_u                          32
    field ist1_l                          32
    padding                               32
    padding                               32
    field rsp2_u                          32
    field rsp2_l                          32
    field rsp1_u                          32
    field rsp1_l                          32
    field rsp0_u                          32
    field rsp0_l                          32
    padding                               32
}

-- PML4, PDPE, PDs and PTs, assuming 51-bit physical address
base 64(51,0)

block pml4e {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pdpt_base_address   39
    padding                         4
    padding                         1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pdpte_1g {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   21
    padding                         17
    field       pat                 1
    padding                         3
    field       global              1
    field       page_size           1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pdpte_pd {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pd_base_address     39
    padding                         4
    field       page_size           1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

tagged_union pdpte page_size {
    tag         pdpte_1g            1
    tag         pdpte_pd            0
}

block pde_large {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   30
    padding                         8
    field       pat                 1
    padding                         3
    field       global              1
    field       page_size           1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block pde_small {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  pt_base_address     39
    padding                         4
    field       page_size           1
    padding                         1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

tagged_union pde page_size {
    tag pde_small 0
    tag pde_large 1
}

block pte {
    field       xd                  1
    padding                         11
    padding                         1
    field_high  page_base_address   39
    padding                         3
    field       global              1
    field       pat                 1
    field       dirty               1
    field       accessed            1
    field       cache_disabled      1
    field       write_through       1
    field       super_user          1
    field       read_write          1
    field       present             1
}

block cr3 {
    padding                         13
    field_high  pml4_base_address   39
    field       pcid                12
}


Made it better

Made it better


Hello world brainfuck program now makes use of the embed info smart way to go

{
    "type": "manual",
    "input": {
        "path": "../../input/network_cabling_*.txt",
        "amount": 2
    },
    "output": {
        "path": "../../output/network_cabling_*.txt",
        "amount": 2
    }
}

+++++ +++               Set Cell 0 to 8
[
    >++++               Add 4 to Cell 1; this will always set Cell 1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell 2
        >+++            Add 3 to Cell 3
        >+++            Add 3 to Cell 4
        >+              Add 1 to Cell 5
        <<<<-           Decrement the loop counter in Cell 1
    ]                   Loop till Cell 1 is zero; number of iterations is 4
    >+                  Add 1 to Cell 2
    >+                  Add 1 to Cell 3
    >-                  Subtract 1 from Cell 4
    >>+                 Add 1 to Cell 6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell 1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell 0
]                       Loop till Cell 0 is zero; number of iterations is 8

?>?>?>?>?>?>?<<<<<<

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell 2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell 3 to get 101 which is 'e'
+++++ ++..+++.          Likewise for 'llo' from Cell 3
>>.                     Cell 5 is 32 for the space
<-.                     Subtract 1 from Cell 4 for 87 to give a 'W'
<.                      Cell 3 was set to 'o' from the end of 'Hello'
+++.----- -.----- ---.  Cell 3 for 'rl' and 'd'
>>+.                    Add 1 to Cell 5 gives us an exclamation point
>++.                    And finally a newline from Cell 6


Convert triangle.bf to unix format.

Convert triangle.bf to unix format.

Signed-off-by: Austin Seipp <e672e89da89e9883fbf1dfdcea7453aa4c4c7323@gmail.com>


Updated documentation on bridge unrolling


Comments added to one sample

Comments added to one sample


SELFOUR-489: Remove 'bound' field from TCBs

Its probable this was meant to be a boolean flag to represent
whether or not the TCB had a bound notification object. However,
this field is unused and its presence is confusing.

--
-- 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)
--

-- Default base size: uint32_t
base 32

block null_cap {
    padding 32

    padding 28
    field capType 4
}

block untyped_cap {
    field capFreeIndex 27
    field capBlockSize 5

    field_high capPtr 28
    field capType     4
}

block endpoint_cap(capEPBadge, capCanGrant, capCanSend, capCanReceive,
                   capEPPtr, capType) {
    field_high capEPPtr 28
    padding 1
    field capCanGrant 1
    field capCanReceive 1
    field capCanSend 1

    field capEPBadge 28
    field capType 4
}

block notification_cap {
    field capNtfnBadge 28
    padding 2
    field capNtfnCanReceive 1
    field capNtfnCanSend 1

    field_high capNtfnPtr 28
    field capType 4
}

block reply_cap(capReplyMaster, capTCBPtr, capType) {
    padding 32

    field_high capTCBPtr 27
    field capReplyMaster 1
    field capType 4
}

-- The user-visible format of the data word is defined by cnode_capdata, below.
block cnode_cap(capCNodeRadix, capCNodeGuardSize, capCNodeGuard,
                capCNodePtr, capType) {
    padding 4
    field capCNodeGuardSize 5
    field capCNodeRadix 5
    field capCNodeGuard 18

    field_high capCNodePtr 27
    padding 1
    field capType 4
}

block cnode_capdata {
    padding 6
    field guard 18
    field guardSize 5
    padding 3
}

block thread_cap {
    padding              32

    field_high capTCBPtr 28
    field capType         4
}

block irq_control_cap {
    padding       32

    padding       24
    field capType  8
}

block irq_handler_cap {
    padding       24
    field capIRQ   8

    padding       24
    field capType  8
}

block zombie_cap {
    field capZombieID     32

    padding               18
    field capZombieType   6
    field capType         8
}

block domain_cap {
    padding 32

    padding 24
    field capType 8
}

---- Arch-independent object types

-- Endpoint: size = 16 bytes
block endpoint {
    padding 64

    field_high epQueue_head 28
    padding 4

    field_high epQueue_tail 28
    padding 2
    field state 2
}

-- Notification object: size = 16 bytes
block notification {
    field_high ntfnBoundTCB 28
    padding 4

    field ntfnMsgIdentifier 32

    field_high ntfnQueue_head 28
    padding 4

    field_high ntfnQueue_tail 28
    padding 2
    field state 2
}

-- Mapping database (MDB) node: size = 8 bytes
block mdb_node {
    field_high mdbNext 29
    padding 1
    field mdbRevocable 1
    field mdbFirstBadged 1

    field_high mdbPrev 29
    padding 3
}

-- Thread state data
--
-- tsType
-- * Running
-- * Restart
-- * Inactive
-- * BlockedOnReceive
--   - Endpoint
-- * BlockedOnSend
--   - Endpoint
--   - CanGrant
--   - IsCall
--   - IPCBadge
--   - Fault
--     - faultType
--     * CapFault
--       - Address
--       - InReceivePhase
--       - LookupFailure
--         - lufType
--         * InvalidRoot
--         * MissingCapability
--           - BitsLeft
--         * DepthMismatch
--           - BitsFound
--           - BitsLeft
--         * GuardMismatch
--           - GuardFound
--           - BitsLeft
--           - GuardSize
--     * VMFault
--       - Address
--       - FSR
--       - FaultType
--     * UnknownSyscall
--       - Number
--     * UserException
--       - Number
--       - Code
-- * BlockedOnReply
-- * BlockedOnFault
--   - Fault
-- * BlockedOnNotification
--   - Notification
-- * Idle

-- Lookup fault: size = 8 bytes
block invalid_root {
    padding 62
    field lufType 2
}

block missing_capability {
    padding 56
    field bitsLeft 6
    field lufType 2
}

block depth_mismatch {
    padding 50
    field bitsFound 6
    field bitsLeft 6
    field lufType 2
}

block guard_mismatch {
    field guardFound 32
    padding 18
    field bitsLeft 6
    field bitsFound 6
    field lufType 2
}

tagged_union lookup_fault lufType {
    tag invalid_root 0
    tag missing_capability 1
    tag depth_mismatch 2
    tag guard_mismatch 3
}

-- Fault: size = 8 bytes
block null_fault {
    padding 61
    field faultType 3
}

block cap_fault {
    field address 32
    field inReceivePhase 1
    padding 28
    field faultType 3
}

block unknown_syscall {
    field syscallNumber 32
    padding 29
    field faultType 3
}

block user_exception {
    field number 32
    field code 29
    field faultType 3
}

-- Thread state: size = 12 bytes
block thread_state(blockingIPCBadge, blockingIPCCanGrant, blockingIPCIsCall,
                   tcbQueued, blockingObject,
                   tsType) {
    field blockingIPCBadge 28
    field blockingIPCCanGrant 1
    field blockingIPCIsCall 1
    padding 2

    -- this is fastpath-specific. it is useful to be able to write
    -- tsType and without changing tcbQueued
    padding 31
    field tcbQueued 1

    field_high blockingObject 28
    field tsType 4
}

--
-- 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)
--

-- Default base size: uint32_t
base 32

block null_cap {
    padding 32

    padding 28
    field capType 4
}

block untyped_cap {
    field capFreeIndex 27
    field capBlockSize 5

    field_high capPtr 28
    field capType     4
}

block endpoint_cap(capEPBadge, capCanGrant, capCanSend, capCanReceive,
                   capEPPtr, capType) {
    field_high capEPPtr 28
    padding 1
    field capCanGrant 1
    field capCanReceive 1
    field capCanSend 1

    field capEPBadge 28
    field capType 4
}

block notification_cap {
    field capNtfnBadge 28
    padding 2
    field capNtfnCanReceive 1
    field capNtfnCanSend 1

    field_high capNtfnPtr 28
    field capType 4
}

block reply_cap(capReplyMaster, capTCBPtr, capType) {
    padding 32

    field_high capTCBPtr 27
    field capReplyMaster 1
    field capType 4
}

-- The user-visible format of the data word is defined by cnode_capdata, below.
block cnode_cap(capCNodeRadix, capCNodeGuardSize, capCNodeGuard,
                capCNodePtr, capType) {
    padding 4
    field capCNodeGuardSize 5
    field capCNodeRadix 5
    field capCNodeGuard 18

    field_high capCNodePtr 27
    padding 1
    field capType 4
}

block cnode_capdata {
    padding 6
    field guard 18
    field guardSize 5
    padding 3
}

block thread_cap {
    padding              32

    field_high capTCBPtr 28
    field capType         4
}

block irq_control_cap {
    padding       32

    padding       24
    field capType  8
}

block irq_handler_cap {
    padding       24
    field capIRQ   8

    padding       24
    field capType  8
}

block zombie_cap {
    field capZombieID     32

    padding               18
    field capZombieType   6
    field capType         8
}

block domain_cap {
    padding 32

    padding 24
    field capType 8
}

---- Arch-independent object types

-- Endpoint: size = 16 bytes
block endpoint {
    padding 64

    field_high epQueue_head 28
    padding 4

    field_high epQueue_tail 28
    padding 2
    field state 2
}

-- Notification object: size = 16 bytes
block notification {
    field_high ntfnBoundTCB 28
    padding 4

    field ntfnMsgIdentifier 32

    field_high ntfnQueue_head 28
    padding 4

    field_high ntfnQueue_tail 28
    padding 1
    field bound 1
    field state 2
}

-- Mapping database (MDB) node: size = 8 bytes
block mdb_node {
    field_high mdbNext 29
    padding 1
    field mdbRevocable 1
    field mdbFirstBadged 1

    field_high mdbPrev 29
    padding 3
}

-- Thread state data
--
-- tsType
-- * Running
-- * Restart
-- * Inactive
-- * BlockedOnReceive
--   - Endpoint
-- * BlockedOnSend
--   - Endpoint
--   - CanGrant
--   - IsCall
--   - IPCBadge
--   - Fault
--     - faultType
--     * CapFault
--       - Address
--       - InReceivePhase
--       - LookupFailure
--         - lufType
--         * InvalidRoot
--         * MissingCapability
--           - BitsLeft
--         * DepthMismatch
--           - BitsFound
--           - BitsLeft
--         * GuardMismatch
--           - GuardFound
--           - BitsLeft
--           - GuardSize
--     * VMFault
--       - Address
--       - FSR
--       - FaultType
--     * UnknownSyscall
--       - Number
--     * UserException
--       - Number
--       - Code
-- * BlockedOnReply
-- * BlockedOnFault
--   - Fault
-- * BlockedOnNotification
--   - Notification
-- * Idle

-- Lookup fault: size = 8 bytes
block invalid_root {
    padding 62
    field lufType 2
}

block missing_capability {
    padding 56
    field bitsLeft 6
    field lufType 2
}

block depth_mismatch {
    padding 50
    field bitsFound 6
    field bitsLeft 6
    field lufType 2
}

block guard_mismatch {
    field guardFound 32
    padding 18
    field bitsLeft 6
    field bitsFound 6
    field lufType 2
}

tagged_union lookup_fault lufType {
    tag invalid_root 0
    tag missing_capability 1
    tag depth_mismatch 2
    tag guard_mismatch 3
}

-- Fault: size = 8 bytes
block null_fault {
    padding 61
    field faultType 3
}

block cap_fault {
    field address 32
    field inReceivePhase 1
    padding 28
    field faultType 3
}

block unknown_syscall {
    field syscallNumber 32
    padding 29
    field faultType 3
}

block user_exception {
    field number 32
    field code 29
    field faultType 3
}

-- Thread state: size = 12 bytes
block thread_state(blockingIPCBadge, blockingIPCCanGrant, blockingIPCIsCall,
                   tcbQueued, blockingObject,
                   tsType) {
    field blockingIPCBadge 28
    field blockingIPCCanGrant 1
    field blockingIPCIsCall 1
    padding 2

    -- this is fastpath-specific. it is useful to be able to write
    -- tsType and without changing tcbQueued
    padding 31
    field tcbQueued 1

    field_high blockingObject 28
    field tsType 4
}


Fixed failing test

Fixed failing test

Fixed failing test caused by puntuation in commments


Use a more verbose code in the hello.bf program.

The new version (from English Wikipedia) is more understandable.

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is a "comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
++++++++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6


adding a trace as an exmaple

adding a trace as an exmaple

+++++ +++               Set Cell 0 to 8
[
    >++++               Add 4 to Cell 1; this will always set Cell 1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell 2
        >+++            Add 3 to Cell 3
        >+++            Add 3 to Cell 4
        >+              Add 1 to Cell 5
        <<<<-           Decrement the loop counter in Cell 1
    ]                   Loop till Cell 1 is zero; number of iterations is 4
    >+                  Add 1 to Cell 2
    >+                  Add 1 to Cell 3
    >-                  Subtract 1 from Cell 4
    >>+                 Add 1 to Cell 6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell 1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell 0
]                       Loop till Cell 0 is zero; number of iterations is 8

?>?>?>?>?>?>?<<<<<<

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell 2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell 3 to get 101 which is 'e'
+++++ ++..+++.          Likewise for 'llo' from Cell 3
>>.                     Cell 5 is 32 for the space
<-.                     Subtract 1 from Cell 4 for 87 to give a 'W'
<.                      Cell 3 was set to 'o' from the end of 'Hello'
+++.----- -.----- ---.  Cell 3 for 'rl' and 'd'
>>+.                    Add 1 to Cell 5 gives us an exclamation point
>++.                    And finally a newline from Cell 6

+++++ +++               Set Cell 0 to 8
[
    >++++               Add 4 to Cell 1; this will always set Cell 1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell 2
        >+++            Add 3 to Cell 3
        >+++            Add 3 to Cell 4
        >+              Add 1 to Cell 5
        <<<<-           Decrement the loop counter in Cell 1
    ]                   Loop till Cell 1 is zero; number of iterations is 4
    >+                  Add 1 to Cell 2
    >+                  Add 1 to Cell 3
    >-                  Subtract 1 from Cell 4
    >>+                 Add 1 to Cell 6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell 1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell 0
]                       Loop till Cell 0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell 2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell 3 to get 101 which is 'e'
+++++ ++..+++.          Likewise for 'llo' from Cell 3
>>.                     Cell 5 is 32 for the space
<-.                     Subtract 1 from Cell 4 for 87 to give a 'W'
<.                      Cell 3 was set to 'o' from the end of 'Hello'
+++.----- -.----- ---.  Cell 3 for 'rl' and 'd'
>>+.                    Add 1 to Cell 5 gives us an exclamation point
>++.                    And finally a newline from Cell 6


Update Brainfuck to output 'hello world'

For consistency with other languages.


More optimal solution

More optimal solution


fix: a bug. empty input was not accepted


fix: comment style

fix: comment style


fix test.bf


tweak

tweak

(This example's from the Wikipedia page for Brainfuck; which doesn't name an author)

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is an "initial comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
++++++++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6

(Taken from the wikipedia page for Brainfuck; which doesn't name an author)

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is an "initial comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
++++++++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6