-- PSL - Nodes definition. This is in fact -*- Ada -*- -- Copyright (C) 2002-2016 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL 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 General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with Ada.Unchecked_Conversion; with Tables; with PSL.Errors; with PSL.Hash; with PSL.Nodes_Meta; use PSL.Nodes_Meta; package body PSL.Nodes is -- Suppress the access check of the table base. This is really safe to -- suppress this check because the table base cannot be null. pragma Suppress (Access_Check); -- Suppress the index check on the table. -- Could be done during non-debug, since this may catch errors (reading -- Null_Node. --pragma Suppress (Index_Check); type Format_Type is ( Format_Short ); -- Common fields are: -- Flag1 : Boolean -- Flag2 : Boolean -- Flag3 : Boolean -- Flag4 : Boolean -- Flag5 : Boolean -- Flag6 : Boolean -- Nkind : Kind_Type -- State1 : Bit2_Type -- State2 : Bit2_Type -- Location : Int32 -- Field1 : Node -- Field2 : Node -- Field3 : Node -- Field4 : Node -- Fields of Format_Short: -- Field5 : Node -- Field6 : Node type State_Type is range 0 .. 3; type Bit3_Type is range 0 .. 7; type Node_Record is record Kind : Nkind; Flag1 : Boolean; Flag2 : Boolean; Flag3 : Boolean; Flag4 : Boolean; Flag5 : Boolean; Flag6 : Boolean; Flag7 : Boolean; Flag8 : Boolean; Flag9 : Boolean; Flag10 : Boolean; Flag11 : Boolean; Flag12 : Boolean; Flag13 : Boolean; Flag14 : Boolean; Flag15 : Boolean; Flag16 : Boolean; State1 : State_Type; B3_1 : Bit3_Type; Flag17 : Boolean; Flag18 : Boolean; Flag19 : Boolean; Location : Int32; Field1 : Node; Field2 : Node; Field3 : Node; Field4 : Node; Field5 : Node; Field6 : Node; end record; pragma Pack (Node_Record); for Node_Record'Size use 8 * 32; package Nodet is new Tables (Table_Component_Type => Node_Record, Table_Index_Type => Node, Table_Low_Bound => 1, Table_Initial => 1024); Init_Node : constant Node_Record := (Kind => N_Error, Flag1 => False, Flag2 => False, State1 => 0, B3_1 => 0, Location => 0, Field1 => 0, Field2 => 0, Field3 => 0, Field4 => 0, Field5 => 0, Field6 => 0, others => False); Free_Nodes : Node := Null_Node; function Get_Last_Node return Node is begin return Nodet.Last; end Get_Last_Node; function Node_To_Uns32 is new Ada.Unchecked_Conversion (Source => Node, Target => Uns32); function Uns32_To_Node is new Ada.Unchecked_Conversion (Source => Uns32, Target => Node); function Node_To_Int32 is new Ada.Unchecked_Conversion (Source => Node, Target => Int32); function Int32_To_Node is new Ada.Unchecked_Conversion (Source => Int32, Target => Node); function Node_To_NFA is new Ada.Unchecked_Conversion (Source => Node, Target => NFA); function NFA_To_Node is new Ada.Unchecked_Conversion (Source => NFA, Target => Node); function Node_To_HDL_Node is new Ada.Unchecked_Conversion (Source => Node, Target => HDL_Node); function HDL_Node_To_Node is new Ada.Unchecked_Conversion (Source => HDL_Node, Target => Node); procedure Set_Kind (N : Node; K : Nkind) is begin Nodet.Table (N).Kind := K; end Set_Kind; function Get_Kind (N : Node) return Nkind is begin return Nodet.Table (N).Kind; end Get_Kind; procedure Set_Flag1 (N : Node; Flag : Boolean) is begin Nodet.Table (N).Flag1 := Flag; end Set_Flag1; function Get_Flag1 (N : Node) return Boolean is begin return Nodet.Table (N).Flag1; end Get_Flag1; procedure Set_Flag2 (N : Node; Flag : Boolean) is begin Nodet.Table (N).Flag2 := Flag; end Set_Flag2; function Get_Flag2 (N : Node) return Boolean is begin return Nodet.Table (N).Flag2; end Get_Flag2; procedure Set_State1 (N : Node; S : State_Type) is begin Nodet.Table (N).State1 := S; end Set_State1; function Get_State1 (N : Node) return State_Type is begin return Nodet.Table (N).State1; end Get_State1; function Get_Location (N : Node) return Location_Type is begin return Location_Type (Nodet.Table (N).Location); end Get_Location; procedure Set_Location (N : Node; Loc : Location_Type) is begin Nodet.Table (N).Location := Int32 (Loc); end Set_Location; procedure Set_Field1 (N : Node; V : Node) is begin Nodet.Table (N).Field1 := V; end Set_Field1; function Get_Field1 (N : Node) return Node is begin return Nodet.Table (N).Field1; end Get_Field1; procedure Set_Field2 (N : Node; V : Node) is begin Nodet.Table (N).Field2 := V; end Set_Field2; function Get_Field2 (N : Node) return Node is begin return Nodet.Table (N).Field2; end Get_Field2; function Get_Field3 (N : Node) return Node is begin return Nodet.Table (N).Field3; end Get_Field3; procedure Set_Field3 (N : Node; V : Node) is begin Nodet.Table (N).Field3 := V; end Set_Field3; function Get_Field4 (N : Node) return Node is begin return Nodet.Table (N).Field4; end Get_Field4; procedure Set_Field4 (N : Node; V : Node) is begin Nodet.Table (N).Field4 := V; end Set_Field4; function Get_Field5 (N : Node) return Node is begin return Nodet.Table (N).Field5; end Get_Field5; procedure Set_Field5 (N : Node; V : Node) is begin Nodet.Table (N).Field5 := V; end Set_Field5; function Get_Field6 (N : Node) return Node is begin return Nodet.Table (N).Field6; end Get_Field6; procedure Set_Field6 (N : Node; V : Node) is begin Nodet.Table (N).Field6 := V; end Set_Field6; function Get_Forma
#!/usr/bin/env perl
#
# Script for generating redboot configs, based on brcmImage.pl
#
# Copyright (C) 2015 Álvaro Fernández Rojas <noltari@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
use strict;
use Getopt::Std;
use File::stat;
my $version = "0.1";
my %arg = (
o => 'redboot.script',
s => 0x1000,
f => 0xbe430000,
a => 0x80010000,
l => 0x7c0000,
t => 20,
);
my $prog = $0;
$prog =~ s/^.*\///;
getopts("r:k:o:s:f:a:l:t:vh", \%arg);
die "usage: $prog ~opts~
-r <file> : input rootfs file
-k <file> : input kernel file
-o <file> : output image file, default $arg{o}
-s <size_kb> : redboot script size, default ".sprintf('%d', parse_num($arg{s}))."
-f <baseaddr> : flash base, default ".sprintf('0x%x', parse_num($arg{f}))."
-a <loadaddr> : Kernel load address, default ".sprintf('0x%x', parse_num($arg{a}))."
-l <linux_kb> : linux partition size, default ".sprintf('0x%x', parse_num($arg{l}))."
-t <timeout> : redboot script timeout, default ".sprintf('%d', parse_num($arg{t}))."
-v : be more verbose
-h : help, version $version
EXAMPLES:
$prog -k kern -r rootfs
" if $arg{h} || !$arg{k} || !$arg{r};
sub parse_num
{
my $num = @_[0];
if (index(lc($num), lc("0x")) == 0) {
return hex($num);
} else {
return $num + 0;
}
}
sub gen_script
{
my $kernel_off = parse_num($arg{s});
my $kernel_addr = parse_num($arg{f});
my $kernel_len = stat($arg{k})->size;
my $rootfs_off = $kernel_off + $kernel_len;
my $rootfs_addr = $kernel_addr + $kernel_len;
my $rootfs_len = parse_num($arg{l}) - $kernel_len;
my $rootfs_size = stat($arg{r})->size;
my $load_addr = parse_num($arg{a});
my $timeout = parse_num($arg{t});
if ($arg{v}) {
printf "kernel_off: 0x%x(%u)\n", $kernel_off, $kernel_off;
printf "kernel_addr: 0x%x(%u)\n", $kernel_addr, $kernel_addr;
printf "kernel_len: 0x%x(%u)\n", $kernel_len, $kernel_len;
printf "rootfs_off: 0x%x(%u)\n", $rootfs_off, $rootfs_off;
printf "rootfs_addr: 0x%x(%u)\n", $rootfs_addr, $rootfs_addr;
printf "rootfs_len: 0x%x(%u)\n", $rootfs_len, $rootfs_len;
printf "rootfs_size: 0x%x(%u)\n", $rootfs_size, $rootfs_size;
}
open(FO, ">$arg{o}");
printf FO "fis init -f\n";
printf FO "\n";
printf FO "fconfig boot_script true\n";
printf FO "fconfig boot_script_data\n";
printf FO "fis load -b 0x%x -d kernel\n", $load_addr;
printf FO "exec -c \"noinitrd\" 0x%x\n", $load_addr;
printf FO "\n";
printf FO "fconfig boot_script_timeout %d\n", $timeout;
printf FO "\n";
printf FO "fis create -o 0x%x -f 0x%x -l 0x%x kernel\n", $kernel_off, $kernel_addr, $kernel_len;
printf FO "\n";
printf FO "fis create -o 0x%x -s 0x%x -f 0x%x -l 0x%x rootfs\n", $rootfs_off, $rootfs_size, $rootfs_addr, $rootfs_len;
printf FO "\n";
printf FO "reset\n";
close FO;
}
# MAIN
gen_script();