#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin/../../PerlLib";
use BRCM::GenConfig;

# $p will allow us to GET values from the PROFILE
# $c will allow us to SET (and GET and DRIVER_SETUP) on the config
# file as we transform it from a template to the final config

# arguments
# * profile file
# * config  file
my $p    = new BRCM::GenConfig(shift);
my $chip = $p->get('BRCM_CHIP');
my $c    = new BRCM::GenConfig( shift, Chip => $chip, Profile => $p );

if ( $p->get("BRCM_IKOS") ) {
    $c->set( [qw[
CONFIG_MTD
]], undef );

#    $c->unset("CONFIG_SMP");
    $c->set("CONFIG_SQUASHFS_ZLIB", 'y');
    $c->unset("CONFIG_BCM_PKTDMA");
    $c->set("CONFIG_BOOT_RAW", 'y');
   
 if ( $p->get("BRCM_QEMU") ) {
     if ( $p->get("BRCM_IKOS") ) {
    	 $c->unset("CONFIG_DEBUG_LL_UART_NONE");
         $c->set( 'CONFIG_ARM_AMBA',                    'y' );
         $c->set( "CONFIG_DEBUG_LL_UART_PL01X",		"y" );
         $c->set( "CONFIG_DEBUG_UART_PHYS",		"0xff812000" );
         $c->set( "CONFIG_DEBUG_UART_VIRT",		"0xf0812000" );	
     }
 }
 else {
   $c->set( [qw[CONFIG_INET]], undef );
 }
}

if ( $p->get("BRCM_QEMU") ) {
    $c->set( 'CONFIG_INET',        'y' );
    $c->set( 'CONFIG_PCI',         'y' );
    $c->set( 'CONFIG_VIRTIO',      'y' );
    $c->set( 'CONFIG_VIRTIO_BLK',  'y' );
    $c->set( 'CONFIG_VIRTIO_NET',  'y' );
    $c->set( 'CONFIG_VIRTIO_CONSOLE',  'y' );
    $c->set( 'CONFIG_VIRTIO_PCI',  'y' );
    $c->set( 'CONFIG_VIRTIO_PCI_LEGACY',  'y' );
    $c->set( 'CONFIG_VIRTIO_MENU',  'y' );
    $c->set( 'CONFIG_VIRTIO_BALLOON',  'y' );
    $c->set( 'CONFIG_VIRTIO_MMIO',  'y' );
    $c->set( 'CONFIG_PCI_HOST_GENERIC',      'y' );
    $c->set( 'CONFIG_NET_9P',      'y' );
    $c->set( 'CONFIG_NET_9P_VIRTIO', 'y' );
    $c->set( 'CONFIG_NET_9P_DEBUG',  'y' );
    $c->set( 'CONFIG_NETWORK_FILESYSTEMS', 'y' );
    $c->set( 'CONFIG_9P_FS',      'y' );
    $c->set( 'CONFIG_9P_FS_POSIX_ACL',  'y' );
}

$c->write();

