LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: =?unknown-8bit?Q?Gy=F6rgy?= 'nog' Jeney<nog@s...>
    Date: Tue Mar 29 18:12:47 CEST 2005
    Subject: [openrisc] [or1ksim #68] Add enabled parameter to all peripherals
    Top
    Hi,

    This adds an enabled keyword to every peripheral to be able to easily enable/
    disable them. (Although the only ones that had them 'till now was the ps2kbd/
    fb and mc peripherals).

    ChangeLog:
    * Add an optional `enabled' paramter to every peripheral.

    nog.
    -------------- next part --------------
    diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/16450.c peripheral/16450.c
    --- /home/nog/or1ksim-split/peripheral/16450.c 2005-03-22 17:07:17.000000000 +0100
    +++ peripheral/16450.c 2005-03-29 16:57:11.000000000 +0200
    @@ -734,6 +735,12 @@ void uart_vapi_id(union param_val val, v
    uart->vapi_id = val.int_val;
    }

    +void uart_enabled(union param_val val, void *dat)
    +{
    + struct dev_16450 *uart = dat;
    + uart->enabled = val.int_val;
    +}
    +
    void *uart_sec_start(void)
    {
    struct dev_16450 *new = malloc(sizeof(struct dev_16450));
    @@ -743,6 +750,7 @@ void *uart_sec_start(void)
    exit(-1);
    }

    + new->enabled = 1;
    new->channel_str = NULL;
    new->channel = NULL;
    new->vapi_id = 0;
    @@ -754,6 +762,10 @@ void uart_sec_end(void *dat)
    {
    struct dev_16450 *uart = dat;

    + if(!uart->enabled) {
    + free(dat);
    + return;
    + }
    register_memoryarea(uart->baseaddr, UART_ADDR_SPACE, 1, 0, uart_read_byte,
    uart_write_byte, dat);
    reg_sim_reset(uart_reset, dat);
    @@ -766,6 +778,7 @@ void reg_uart_sec(void)
    uart_sec_end);

    reg_config_param(sec, "baseaddr", paramt_addr, uart_baseaddr);
    + reg_config_param(sec, "enabled", paramt_int, uart_enabled);
    reg_config_param(sec, "irq", paramt_int, uart_irq);
    reg_config_param(sec, "16550", paramt_int, uart_16550);
    reg_config_param(sec, "jitter", paramt_int, uart_jitter);
    diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/16450.h peripheral/16450.h
    --- /home/nog/or1ksim-split/peripheral/16450.h 2005-02-25 16:56:21.000000000 +0100
    +++ peripheral/16450.h 2005-03-29 16:43:29.000000000 +0200
    @@ -100,6 +100,7 @@ struct dev_16450 {
    struct channel *channel;

    /* Configuration */
    + int enabled;
    int jitter;
    oraddr_t baseaddr;
    int irq;
    diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/atahost.c peripheral/atahost.c
    --- /home/nog/or1ksim-split/peripheral/atahost.c 2005-02-25 16:56:21.000000000 +0100
    +++ peripheral/atahost.c 2005-03-29 16:43:57.000000000 +0200
    @@ -317,6 +317,12 @@ void ata_dev_packet1(union param_val val
    ata->devices.device1.packet = val.int_val;
    }

    +void ata_enabled(union param_val val, void *dat)
    +{
    + ata_host *ata = dat;
    + ata->enabled = val.int_val;
    +}
    +
    void *ata_sec_start(void)
    {
    ata_host *new = malloc(sizeof(ata_host));
    @@ -327,6 +333,7 @@ void *ata_sec_start(void)
    }

    memset(new, 0, sizeof(ata_host));
    + new->enabled = 1;
    return new;
    }

    @@ -334,6 +341,11 @@ void ata_sec_end(void *dat)
    {
    ata_host *ata = dat;

    + if(!ata->enabled) {
    + free(dat);
    + return;
    + }
    +
    /* Connect ata_devices. */
    ata_devices_init(&ata->devices);

    @@ -347,6 +359,7 @@ void reg_ata_sec(void)
    { struct config_section *sec = reg_config_sec("ata", ata_sec_start, ata_sec_end); + reg_config_param(sec, "enabled", paramt_int, ata_enabled); reg_config_param(sec, "baseaddr", paramt_addr, ata_baseaddr); reg_config_param(sec, "irq", paramt_int, ata_irq); reg_config_param(sec, "dev_type0", paramt_int, ata_dev_type0); diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/atahost.h peripheral/atahost.h --- /home/nog/or1ksim-split/peripheral/atahost.h 2005-02-25 16:56:21.000000000 +0100 +++ peripheral/atahost.h 2005-03-29 16:44:09.000000000 +0200 @@ -102,6 +102,9 @@ /* ----- Structs ----- */ /* ---------------------------- */ typedef struct{ + /* Is peripheral enabled? */ + int enabled; + /* Base address in memory */ oraddr_t baseaddr; diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/dma.c peripheral/dma.c --- /home/nog/or1ksim-split/peripheral/dma.c 2005-03-22 17:23:30.000000000 +0100 +++ peripheral/dma.c 2005-03-29 16:51:16.000000000 +0200 @@ -498,6 +483,12 @@ void dma_vapi_id(union param_val val, vo dma->vapi_id = val.int_val; } +void dma_enabled(union param_val val, void *dat) +{ + struct dma_controller *dma = dat; + dma->enabled = val.int_val; +} + void *dma_sec_start(void) { struct dma_controller *new = malloc(sizeof(struct dma_controller)); @@ -508,6 +499,7 @@ void *dma_sec_start(void) } new->next = NULL; + new->enabled = 1; return new; } @@ -517,6 +509,11 @@ void dma_sec_end(void *dat) struct dma_controller *dma = dat; struct dma_controller *cur; + if(!dma->enabled) { + free(dat); + return; + } + register_memoryarea( dma->baseaddr, DMA_ADDR_SPACE, 4, 0, dma_read32, dma_write32, dat ); reg_sim_reset( dma_reset, dat ); reg_sim_stat( dma_status, dat ); @@ -533,6 +530,7 @@ void reg_dma_sec(void) struct config_section *sec = reg_config_sec("dma", dma_sec_start, dma_sec_end); reg_config_param(sec, "irq", paramt_int, dma_irq); + reg_config_param(sec, "enabled", paramt_int, dma_enabled); reg_config_param(sec, "baseaddr", paramt_addr, dma_baseaddr); reg_config_param(sec, "vapi_id", paramt_addr, dma_vapi_id); } diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/dma.h peripheral/dma.h --- /home/nog/or1ksim-split/peripheral/dma.h 2005-02-25 16:56:24.000000000 +0100 +++ peripheral/dma.h 2005-03-29 16:44:48.000000000 +0200 @@ -62,6 +62,9 @@ struct dma_channel /* Implementation of DMA Controller Registers and State */ struct dma_controller { + /* Is peripheral enabled */ + int enabled; + /* Base address in memory */ oraddr_t baseaddr; diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/eth.c peripheral/eth.c --- /home/nog/or1ksim-split/peripheral/eth.c 2005-03-22 16:57:30.000000000 +0100 +++ peripheral/eth.c 2005-03-29 16:52:01.000000000 +0200 @@ -864,6 +866,12 @@ void eth_vapi_id(union param_val val, vo eth->base_vapi_id = val.int_val; } +void eth_enabled(union param_val val, void *dat) +{ + struct eth_device *eth = dat; + eth->enabled = val.int_val; +} + void *eth_sec_start(void) { struct eth_device *new = malloc(sizeof(struct eth_device)); @@ -873,6 +881,8 @@ void *eth_sec_start(void) exit(-1); } + new->enabled = 1; + return new; } @@ -880,6 +890,11 @@ void eth_sec_end(void *dat) { struct eth_device *eth = dat; + if(!eth->enabled) { + free(dat); + return; + } + register_memoryarea( eth->baseaddr, ETH_ADDR_SPACE, 4, 0, eth_read32, eth_write32, dat ); reg_sim_stat( eth_status, dat ); reg_sim_reset( eth_reset, dat ); @@ -890,6 +905,7 @@ void reg_ethernet_sec(void) struct config_section *sec = reg_config_sec("ethernet", eth_sec_start, eth_sec_end); reg_config_param(sec, "irq", paramt_int, eth_irq); + reg_config_param(sec, "enabled", paramt_int, eth_enabled); reg_config_param(sec, "baseaddr", paramt_int, eth_baseaddr); reg_config_param(sec, "dma", paramt_int, eth_dma); reg_config_param(sec, "rtx_type", paramt_int, eth_rtx_type); diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/ethernet_i.h peripheral/ethernet_i.h --- /home/nog/or1ksim-split/peripheral/ethernet_i.h 2005-02-25 16:56:26.000000000 +0100 +++ peripheral/ethernet_i.h 2005-03-29 16:45:32.000000000 +0200 @@ -128,6 +128,9 @@ enum { ETH_VAPI_DATA = 0, struct eth_device { + /* Is peripheral enabled */ + int enabled; + /* Base address in memory */ oraddr_t baseaddr; diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/fb.c peripheral/fb.c --- /home/nog/or1ksim-split/peripheral/fb.c 2005-03-24 18:08:57.000000000 +0100 +++ peripheral/fb.c 2005-03-29 16:46:03.000000000 +0200 @@ -36,6 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridg #define FB_WRAP (512*1024) struct fb_state { + int enabled; unsigned long pal[256]; int ctrl; int pic; @@ -333,6 +332,12 @@ void fb_filename(union param_val val, vo } } +void fb_enabled(union param_val val, void *dat) +{ + struct fb_state *fb = dat; + fb->enabled = val.int_val; +} + void *fb_sec_start(void) { struct fb_state *new = malloc(sizeof(struct fb_state)); @@ -352,6 +357,7 @@ void *fb_sec_start(void) new->camerax = 0; new->cameray = 0; new->camera_pos = 0; + new->enabled = 1; return new; } @@ -360,6 +366,11 @@ void fb_sec_end(void *dat) { struct fb_state *fb = dat; + if(!fb->enabled) { + free(dat); + return; + } + if (fb->baseaddr) register_memoryarea(fb->baseaddr, FB_PAL + 256*4, 4, 0, fb_read32, fb_write32, dat); @@ -371,6 +382,7 @@ void reg_fb_sec(void) struct config_section *sec = reg_config_sec("fb", fb_sec_start, fb_sec_end); reg_config_param(sec, "baseaddr", paramt_addr, fb_baseaddr); + reg_config_param(sec, "enabled", paramt_int, fb_enabled); reg_config_param(sec, "refresh_rate", paramt_int, fb_refresh_rate); reg_config_param(sec, "filename", paramt_str, fb_filename); } diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/gpio.c peripheral/gpio.c --- /home/nog/or1ksim-split/peripheral/gpio.c 2005-03-22 16:57:30.000000000 +0100 +++ peripheral/gpio.c 2005-03-29 16:46:33.000000000 +0200 @@ -250,6 +250,12 @@ void gpio_base_vapi_id(union param_val v gpio->base_vapi_id = val.int_val; } +void gpio_enabled(union param_val val, void *dat) +{ + struct gpio_device *gpio = dat; + gpio->enabled = val.int_val; +} + void *gpio_sec_start(void) { struct gpio_device *new = malloc(sizeof(struct gpio_device)); @@ -263,6 +269,8 @@ void *gpio_sec_start(void) memset(&new->curr, 0, sizeof(new->curr)); memset(&new->next, 0, sizeof(new->next)); + new->enabled = 1; + return new; } @@ -270,6 +278,11 @@ void gpio_sec_end(void *dat) { struct gpio_device *gpio = dat; + if(!gpio->enabled) { + free(dat); + return; + } + /* Register memory range */ register_memoryarea( gpio->baseaddr, GPIO_ADDR_SPACE, 4, 0, gpio_read32, gpio_write32, dat ); @@ -281,6 +294,7 @@ void reg_gpio_sec(void) { struct config_section *sec = reg_config_sec("gpio", gpio_sec_start, gpio_sec_end); + reg_config_param(sec, "enabled", paramt_int, gpio_enabled); reg_config_param(sec, "baseaddr", paramt_addr, gpio_baseaddr); reg_config_param(sec, "irq", paramt_int, gpio_irq); reg_config_param(sec, "base_vapi_id", paramt_int, gpio_base_vapi_id); diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/gpio_i.h peripheral/gpio_i.h --- /home/nog/or1ksim-split/peripheral/gpio_i.h 2005-02-09 18:03:55.000000000 +0100 +++ peripheral/gpio_i.h 2005-03-29 16:52:35.000000000 +0200 @@ -43,6 +43,9 @@ enum { GPIO_VAPI_DATA = 0, */ struct gpio_device { + /* Is peripheral enabled */ + int enabled; + /* Base address in memory */ oraddr_t baseaddr; diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/mc.c peripheral/mc.c --- /home/nog/or1ksim-split/peripheral/mc.c 2005-02-25 16:58:26.000000000 +0100 +++ peripheral/mc.c 2005-03-29 16:57:36.000000000 +0200 @@ -233,11 +233,15 @@ void mc_sec_end(void *dat) { struct mc *mc = dat; - if(mc->enabled) { - register_memoryarea(mc->baseaddr, MC_ADDR_SPACE, 4, 1, mc_read_word, mc_write_word, dat); - reg_sim_reset(mc_reset, dat); - reg_sim_stat(mc_status, dat); + if(!mc->enabled) { + free(dat); + return; } + + register_memoryarea(mc->baseaddr, MC_ADDR_SPACE, 4, 1, mc_read_word, + mc_write_word, dat); + reg_sim_reset(mc_reset, dat); + reg_sim_stat(mc_status, dat); } void reg_mc_sec(void) diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/ps2kbd.c peripheral/ps2kbd.c --- /home/nog/or1ksim-split/peripheral/ps2kbd.c 2005-03-24 18:08:57.000000000 +0100 +++ peripheral/ps2kbd.c 2005-03-29 16:48:32.000000000 +0200 @@ -96,6 +96,7 @@ struct kbd_state { long slowdown; /* Cofiguration */ + int enabled; int irq; oraddr_t baseaddr; char *rxfile; @@ -316,6 +315,12 @@ void kbd_rxfile(union param_val val, voi } } +void kbd_enabled(union param_val val, void *dat) +{ + struct kbd_state *kbd = dat; + kbd->enabled = val.int_val; +} + void *kbd_sec_start(void) { struct kbd_state *new = malloc(sizeof(struct kbd_state)); @@ -329,6 +334,7 @@ void *kbd_sec_start(void) new->buf_head = 0; new->buf_tail = 0; new->rxfs = NULL; + new->enabled = 1; return new; } @@ -337,6 +343,11 @@ void kbd_sec_end(void *dat) { struct kbd_state *kbd = dat; + if(!kbd->enabled) { + free(dat); + return; + } + register_memoryarea(kbd->baseaddr, KBD_SPACE, 1, 0, kbd_read8, kbd_write8, dat); reg_sim_reset(kbd_reset, dat); reg_sim_stat(kbd_info, dat); @@ -346,7 +357,8 @@ void reg_kbd_sec(void) { struct config_section *sec = reg_config_sec("kbd", kbd_sec_start, kbd_sec_end); - reg_config_param(sec, "baseaddr", paramt_int, kbd_baseaddr); + reg_config_param(sec, "baseaddr", paramt_addr, kbd_baseaddr); + reg_config_param(sec, "enabled", paramt_int, kbd_enabled); reg_config_param(sec, "irq", paramt_int, kbd_irq); reg_config_param(sec, "rxfile", paramt_str, kbd_rxfile); } diff -urp --unidirectional-new-file /home/nog/or1ksim-split/peripheral/vga.c peripheral/vga.c --- /home/nog/or1ksim-split/peripheral/vga.c 2005-03-22 16:57:30.000000000 +0100 +++ peripheral/vga.c 2005-03-29 16:50:17.000000000 +0200 @@ -35,6 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridg /* When this counter reaches config.vgas[].refresh_rate, a screenshot is taken and outputted */ struct vga_state { + int enabled; int pics; unsigned long ctrl, stat, htim, vtim; int vbindex; @@ -262,6 +261,12 @@ void vga_filename(union param_val val, v if(!(vga->filename = strdup (val.str_val))); } +void vga_enabled(union param_val val, void *dat) +{ + struct vga_state *vga = dat; + vga->enabled = 1; +} + void *vga_sec_start(void) { struct vga_state *new = malloc(sizeof(struct vga_state)); @@ -272,6 +277,7 @@ void *vga_sec_start(void) } new->baseaddr = 0; + new->enabled = 1; return new; } @@ -280,6 +286,11 @@ void vga_sec_end(void *dat) { struct vga_state *vga = dat; + if(!vga->enabled) { + free(dat); + return; + } + if (vga->baseaddr) register_memoryarea(vga->baseaddr, VGA_ADDR_SPACE, 4, 0, vga_read32, vga_write32, dat); @@ -291,6 +302,7 @@ void reg_vga_sec(void) struct config_section *sec = reg_config_sec("vga", vga_sec_start, vga_sec_end); reg_config_param(sec, "baseaddr", paramt_addr, vga_baseaddr); + reg_config_param(sec, "enabled", paramt_int, vga_enabled); reg_config_param(sec, "irq", paramt_int, vga_irq); reg_config_param(sec, "refresh_rate", paramt_int, vga_refresh_rate); reg_config_param(sec, "filename", paramt_str, vga_filename); --- /home/nog/or1ksim-split/sim.cfg 2005-02-25 16:55:54.000000000 +0100 +++ sim.cfg 2005-03-29 17:33:15.000000000 +0200 @@ -580,6 +580,9 @@ This section configures the UARTs + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> address of first UART register for this device @@ -631,6 +634,7 @@ */ section uart + enabled = 1 baseaddr = 0x90000000 irq = 2 channel = "file:uart0.rx,uart0.tx" @@ -643,6 +647,9 @@ This section configures the DMAs + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> address of first DMA register for this device @@ -654,6 +661,7 @@ */ section dma + enabled = 1 baseaddr = 0x9a000000 irq = 11 end @@ -663,6 +671,9 @@ This section configures the ETHERNETs + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> address of first ethernet register for this device @@ -695,6 +706,7 @@ */ section ethernet + enabled = 1 baseaddr = 0x92000000 dma = 0 irq = 4 @@ -711,6 +723,9 @@ This section configures the GPIOs + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> address of first GPIO register for this device @@ -723,6 +738,7 @@ */ section gpio + enabled = 1 baseaddr = 0x91000000 irq = 3 base_vapi_id = 0x0200 @@ -732,6 +748,9 @@ This section configures the VGA/LCD controller + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> address of first VGA register @@ -746,6 +765,7 @@ */ section vga + enabled = 1 baseaddr = 0x97100000 irq = 8 refresh_rate = 100000 @@ -774,6 +794,9 @@ This section configures the frame buffer + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + baseaddr = <hex_value> base address of frame buffer @@ -788,6 +811,7 @@ */ section fb + enabled = 1 baseaddr = 0x97000000 refresh_rate = 1000000 filename = "primary" @@ -806,6 +830,7 @@ */ section kbd + enabled = 1 irq = 5 baseaddr = 0x94000000 rxfile = "kbd.rx" @@ -819,6 +844,9 @@ baseaddr = <hex_value> address of first ATA register + enabled = <0|1> + Enable/disable the peripheral. By default if it is enabled. + irq = <value> irq number for this device @@ -853,6 +881,7 @@ */ section ata + enabled = 1 baseaddr = 0x9e000000 irq = 15

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.