struct link_device *lli_create_link_device(struct platform_device *pdev)
{
	struct modem_data *modem;
	struct mem_link_device *mld;
	struct link_device *ld;
	int err;
	unsigned long start;
	unsigned long size;
#ifdef DEBUG_MODEM_IF
	struct dentry *debug_dir = debugfs_create_dir("svnet", NULL);
#endif
	mif_err("+++\n");

	/**
	 * Get the modem (platform) data
	 */
	modem = (struct modem_data *)pdev->dev.platform_data;
	if (!modem) {
		mif_err("ERR! modem == NULL\n");
		return NULL;
	}

	if (!modem->gpio_ap_wakeup) {
		mif_err("ERR! no gpio_ap_wakeup\n");
		return NULL;
	}

	if (!modem->gpio_cp_status) {
		mif_err("ERR! no gpio_cp_status\n");
		return NULL;
	}

	mif_err("MODEM:%s LINK:%s\n", modem->name, modem->link_name);

	/**
	 * Create a MEMORY link device instance
	 */
	mld = mem_create_link_device(MEM_LLI_SHMEM, modem);
	if (!mld) {
		mif_err("%s: ERR! create_link_device fail\n", modem->link_name);
		return NULL;
	}

	g_mld = mld;

	ld = &mld->link_dev;

	ld->ready = lli_link_ready;
	ld->reset = lli_link_reset;
	ld->reload = lli_link_reload;
	ld->off = lli_link_off;

	ld->unmounted = lli_link_unmounted;
	ld->suspended = lli_link_suspended;

	ld->enable_irq = lli_enable_irq;
	ld->disable_irq = lli_disable_irq;

	/**
	 * Link local functions to the corresponding function pointers that are
	 * mandatory for all memory-type link devices
	 */
	mld->send_ap2cp_irq = send_ap2cp_irq;

	/*
	** Link local functions to the corresponding function pointers
	*/
#ifndef CONFIG_LINK_POWER_MANAGEMENT_WITH_FSM
	mld->finalize_cp_start = finalize_cp_start;
#endif

#ifdef CONFIG_LINK_POWER_MANAGEMENT
	mld->start_pm = start_pm;
	mld->stop_pm = stop_pm;
	mld->forbid_cp_sleep = forbid_cp_sleep;
	mld->permit_cp_sleep = permit_cp_sleep;
	mld->link_active = check_link_status;
#endif

#ifdef DEBUG_MODEM_IF
	mld->debug_info = mipi_lli_debug_info;
#endif

	/**
	 * Initialize SHMEM maps for IPC (physical map -> logical map)
	 */
	start = mipi_lli_get_phys_base();
	size = mipi_lli_get_phys_size();
	err = mem_register_ipc_rgn(mld, start, size);
	if (err < 0) {
		mif_err("%s: ERR! register_ipc_rgn fail (%d)\n", ld->name, err);
		goto error;
	}
	err = mem_setup_ipc_map(mld);
	if (err < 0) {
		mif_err("%s: ERR! setup_ipc_map fail (%d)\n", ld->name, err);
		mem_unregister_ipc_rgn(mld);
		goto error;
	}

#ifdef CONFIG_LINK_DEVICE_WITH_SBD_ARCH
	if (ld->sbd_ipc) {
		struct sbd_link_device *sld = &mld->sbd_link_dev;

		err = create_sbd_link_device(ld, sld, mld->base, mld->size);
		if (err < 0)
			goto error;
	}
#endif

	/**
	 * Register interrupt handlers
	 */
	err = mipi_lli_register_handler(lli_irq_handler, mld);
	if (err) {
		mif_err("%s: ERR! register_handler fail (%d)\n", ld->name, err);
		goto error;
	}

	/*
	** Retrieve GPIO#, IRQ#, and IRQ flags for PM
	*/
	mld->gpio_ap_wakeup = modem->gpio_ap_wakeup;
	mld->gpio_cp_wakeup = modem->gpio_cp_wakeup;
	mld->gpio_cp_status = modem->gpio_cp_status;
	mld->gpio_ap_status = modem->gpio_ap_status;
	mld->gpio_ipc_int2cp = modem->gpio_ipc_int2cp;

#ifdef CONFIG_LINK_POWER_MANAGEMENT
	err = init_pm(mld);
	if (err)
		goto error;
#endif

#ifdef DEBUG_MODEM_IF
	mld->mem_dump_blob.data = mld->base;
	mld->mem_dump_blob.size = mld->size;
	debugfs_create_blob("mem_dump", S_IRUGO, debug_dir,
						&mld->mem_dump_blob);
#endif

	mif_err("---\n");
	return ld;

error:
	kfree(mld);
	mif_err("xxx\n");
	return NULL;
}
Exemplo n.º 2
0
void bmc_task( void *pvParameters )
{
    ipmbMSG_t       *message;
    ipmbMSG_t       *response;
    int priv;
    unsigned int    priv_pos;
    unsigned char   netfn;
    unsigned char   cmd;


#if defined (CFG_EMMCPM)
    /* init the PM task */
    init_pm();
#endif

    /* set firmware working */
    config_set_fw_ok();

    while (1)
    {

#ifdef CFG_WATCHDOG
        if (!bmc_sched_reset)
        {
            /* reset watchdog timer here */
            taskENTER_CRITICAL();
            lpc_watchdog_reset();
            taskEXIT_CRITICAL();
        }
#endif

        /* wait for data in bmc_rx_queue... */
        if (xQueueReceive(bmc_rx_queue, &message, QUEUE_BLOCK_100))
        {
#ifdef CFG_DEBUG_PERFORMANCE
            unsigned char perf_temp;
            perf_temp = uxQueueMessagesWaiting(bmc_rx_queue);
            if (perf_temp > perf_bmc_rx_waiting) perf_bmc_rx_waiting = perf_temp;
            perf_bmc_task_stack = uxTaskGetStackHighWaterMark(NULL);
#endif
            /* allocate memory for response from global buffer */
            if (!(response = msg_malloc()))
            {
                /* no memory for response -> put message back to queue and retry */
                /* important: DO NOT BLOCK OR MIGHT CAUSE DEADLOCK!!! */

                ERROR_PRINTF((DEBUG_UART, "ERR: %s: Could not msg_malloc() for response.\n", __func__));
                if (xQueueSendToFront(bmc_rx_queue, &message, QUEUE_BLOCK_NONE) != pdPASS)
                {
                    /* set error flag */
                    mon_queues |= MON_QUEUE_BMC_RX;

                    /* delete received message */
                    msg_free(message);
                }
            }
            else
            {
                /* Check the privilege level of the command */
                netfn = message->netFN;
                cmd = message->cmd;
                priv_pos = 1;

                /* decapsulate bridged messages */
                while (netfn == NETFN_APP_RQ && cmd == CMD_SEND_MSG)
                {
                    netfn = message->data[priv_pos + 1] >> 2;
                    cmd = message->data[priv_pos + 5];
                    priv_pos += 7; /* skip next message header + tracking/channel number */
                }

                priv = IPMI_PRIV_PERMITTED;

#ifdef CFG_LAN
                /* at the moment is the lan interface the only onee with authentication */
                if(message->orig_channel == MSG_CHANNEL_LAN)
                {
                    /* determine if the given command is allowed in the given privilege level */
                    priv = ipmi_priv_check_privilege(ipmi_lan_get_privilege(0), netfn, cmd);
                }
#endif
                /* handle value retrieved from privilege check */
                switch (priv)
                {
                case IPMI_PRIV_PERMITTED:
                    /* answer to the message with a local response */
                    bmc_respond(message, response);
                    break;

                case IPMI_PRIV_SEND:
                case IPMI_PRIV_DENIED:
                case IPMI_PRIV_BOOT:
                    /* build response command */
                    response->rsSA  = message->rqSA;
                    response->netFN = (message->netFN | 0x01);          /* response */
                    response->rsLUN = message->rqLUN;
                    response->rqSA  = global_data.bmc_ipmb_addr;        /* BMC's IPMB address */
                    response->rqSeq = message->rqSeq;
                    response->rqLUN = message->rsLUN;
                    response->cmd   = message->cmd;
                    response->orig_channel = message->dest_channel;     /* swap destination and origin channel */
                    response->dest_channel = message->orig_channel;
                    response->data[0] = CC_INSUFFICIENT_PRIVILEGE_LEVEL;
                    response->data_len = 1;
                    break;

                case IPMI_PRIV_INVALID:
                default:
                    /* build response command */
                    response->rsSA  = message->rqSA;
                    response->netFN = (message->netFN | 0x01);          /* response */
                    response->rsLUN = message->rqLUN;
                    response->rqSA  = global_data.bmc_ipmb_addr;        /* BMC's IPMB address */
                    response->rqSeq = message->rqSeq;
                    response->rqLUN = message->rsLUN;
                    response->cmd   = message->cmd;
                    response->orig_channel = message->dest_channel;     /* swap destination and origin channel */
                    response->dest_channel = message->orig_channel;
                    response->data[0] = CC_UNDEFINED;
                    response->data_len = 1;
                    break;
                }

                /* delete received message and send response */
                msg_free(message);

                /* forward reply to msg_hub_rx_queue */
                if (xQueueSend(msg_hub_rx_queue, &response, QUEUE_BLOCK_10) != pdPASS)
                {
                    ERROR_PRINTF((DEBUG_UART, "ERR: %s: msg_hub_rx_queue full\n", __func__));

                    /* set error flag */
                    mon_queues |= MON_QUEUE_MSG_HUB_RX;

                    /* purge response */
                    msg_free(response);
                }
            }
        }
        else
        {
Exemplo n.º 3
0
/* Platform has no romstage entry point under mainboard directory,
 * so this one is named with prefix mainboard.
 */
void mainboard_romstage_entry(unsigned long bist)
{
	sysinfo_t sysinfo;
	int s3resume = 0;
	int cbmem_initted;
	u16 reg16;

	/* basic northbridge setup, including MMCONF BAR */
	gm45_early_init();

	if (bist == 0)
		enable_lapic();

	/* First, run everything needed for console output. */
	i82801ix_early_init();
	setup_pch_gpios(&mainboard_gpio_map);

	mb_setup_lpc();

	mb_setup_superio();

	console_init();
	report_bist_failure(bist);

	reg16 = pci_read_config16(LPC_DEV, D31F0_GEN_PMCON_3);
	pci_write_config16(LPC_DEV, D31F0_GEN_PMCON_3, reg16);
	if ((MCHBAR16(SSKPD_MCHBAR) == 0xCAFE) && !(reg16 & (1 << 9))) {
		printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n");
		gm45_early_reset();
	}

	/* ASPM related setting, set early by original BIOS. */
	DMIBAR16(0x204) &= ~(3 << 10);

	/* Check for S3 resume. */
	s3resume = southbridge_detect_s3_resume();

	/* RAM initialization */
	enter_raminit_or_reset();
	memset(&sysinfo, 0, sizeof(sysinfo));
	get_mb_spd_addrmap(sysinfo.spd_map);
	const struct device *dev;
	dev = pcidev_on_root(2, 0);
	if (dev)
		sysinfo.enable_igd = dev->enabled;
	dev = pcidev_on_root(1, 0);
	if (dev)
		sysinfo.enable_peg = dev->enabled;
	get_gmch_info(&sysinfo);

	mb_pre_raminit_setup(&sysinfo);

	raminit(&sysinfo, s3resume);

	mb_post_raminit_setup();

	const u32 deven = pci_read_config32(MCH_DEV, D0F0_DEVEN);
	/* Disable D4F0 (unknown signal controller). */
	pci_write_config32(MCH_DEV, D0F0_DEVEN, deven & ~0x4000);

	init_pm(&sysinfo, 0);

	i82801ix_dmi_setup();
	gm45_late_init(sysinfo.stepping);
	i82801ix_dmi_poll_vc1();

	MCHBAR16(SSKPD_MCHBAR) = 0xCAFE;

	init_iommu();

	cbmem_initted = !cbmem_recovery(s3resume);

	romstage_handoff_init(cbmem_initted && s3resume);

	printk(BIOS_SPEW, "exit main()\n");
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    ULONG ulType = 0;
    ULONG ulAttr = 0;
    APIRET rc;
    int i;
    int iMode = MODE_NONE;

    rc = DosQueryHType(0, &ulType, &ulAttr);    //STDIN

    if(!rc)
    {
        ulType &= 0xFF;

        if(ulType == 0 || ulType == 2)  //file or pipe
            iMode |= MODE_IN;
    }

    rc = DosQueryHType(1, &ulType, &ulAttr);    //STDOUT

    if(!rc)
    {
        ulType &= 0xFF;

        if(ulType == 0 || ulType == 2)  //file or pipe
            iMode |= MODE_OUT;
    }

    for(i = 1; i < argc; i++)
    {
        if(argv[i][0] == '-' || argv[i][0] == '/')
        {
            switch(argv[i][1])
            {
                case 'I':
                case 'i':
                    if(argv[i][2] == '-')
                        iMode &= ~MODE_IN;
                    else
                        iMode |= MODE_IN;
                    break;

                case 'o':
                case 'O':
                    if(argv[i][2] == '-')
                        iMode &= ~MODE_OUT;
                    else
                        iMode |= MODE_OUT;
                    break;

                case 'h':
                case 'H':
                case '?':
                    usage();
                    return 0;
            }
        }
    }

    if(!iMode)
    {
        usage();
        return 0;
    }

    rc = init_pm();

    if(rc)
        return -1;

    if(iMode & MODE_IN)
    {
        char *str = ReadPipe(0);

        if(str)
            set_clip(str);

        delete str;
    }

    if(iMode & MODE_OUT)
    {
        char *str = get_clip();

        if(str)
        {
            ULONG  ulWrote = 0;
            rc = DosWrite(1, str, strlen(str), &ulWrote);
        }
    }

    done_pm();

    return rc;
}