int parse_triggerfile_cmd(void) { int res, cmd_ind; int opt_cnt; int eof; char cmd[] = "TRIGGER"; char *ptr; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; opt_cnt = 0; gpqual_root = 0; func = 0; TREF(parms_cnt) = 0; /* Parameters count */ *cli_err_str = 0; cmd_ind = find_verb(cmd); assert(-1 != cmd_ind); gpcmd_qual = cmd_ary[cmd_ind].qual_vals; gpcmd_parm_vals = NULL; gpcmd_verb = cmd_ary[cmd_ind].qual_vals; if (gpcmd_qual) clear_parm_vals(gpcmd_qual, TRUE); func = cmd_ary[cmd_ind].func; /* ---------------------- * Parse command options * ---------------------- */ do { res = parse_arg(gpcmd_qual, &eof); } while (1 == res); /* ------------------------------------- * If parse error, display error string * ------------------------------------- */ if (-1 == res) func = 0; else return (0); /* ------------------------- * If gettoken returned EOF * ------------------------- */ if (eof) return (EOF); else return (ERR_MUNOACTION); }
static void codec_init(struct device *dev, u32 base, int addr) { u32 reg32; const u32 *verb; u32 verb_size; int i; printk(BIOS_DEBUG, "Azalia: Initializing codec #%d\n", addr); /* 1 */ if (wait_for_ready(base) == -1) { printk(BIOS_DEBUG, " codec not ready.\n"); return; } reg32 = (addr << 28) | 0x000f0000; write32(base + 0x60, reg32); if (wait_for_valid(base) == -1) { printk(BIOS_DEBUG, " codec not valid.\n"); return; } reg32 = read32(base + 0x64); /* 2 */ printk(BIOS_DEBUG, "Azalia: codec viddid: %08x\n", reg32); verb_size = find_verb(dev, reg32, &verb); if (!verb_size) { printk(BIOS_DEBUG, "Azalia: No verb!\n"); return; } printk(BIOS_DEBUG, "Azalia: verb_size: %d\n", verb_size); /* 3 */ for (i = 0; i < verb_size; i++) { if (wait_for_ready(base) == -1) return; write32(base + 0x60, verb[i]); if (wait_for_valid(base) == -1) return; } printk(BIOS_DEBUG, "Azalia: verb loaded.\n"); }
static void codec_init(void *base, int addr) { u32 dword; u32 *verb; u32 verb_size; int i; /* 1 */ if (wait_for_ready(base) == -1) return; dword = (addr << 28) | 0x000f0000; write32(base + 0x60, dword); if (wait_for_valid(base) == -1) return; dword = read32(base + 0x64); /* 2 */ printk(BIOS_DEBUG, "codec viddid: %08x\n", dword); verb_size = find_verb(dword, &verb); if (!verb_size) { printk(BIOS_DEBUG, "No verb!\n"); return; } printk(BIOS_DEBUG, "verb_size: %d\n", verb_size); /* 3 */ for (i = 0; i < verb_size; i++) { if (wait_for_ready(base) == -1) return; write32(base + 0x60, verb[i]); if (wait_for_valid(base) == -1) return; } printk(BIOS_DEBUG, "verb loaded!\n"); }
static void codec_init(u8 *base, int addr) { u32 dword; u32 *verb; unsigned verb_size; int i; /* 1 */ do { dword = read32(base + 0x68); } while (dword & 1); dword = (addr<<28) | 0x000f0000; write32(base + 0x60, dword); do { dword = read32(base + 0x68); } while ((dword & 3)!=2); dword = read32(base + 0x64); /* 2 */ printk(BIOS_DEBUG, "codec viddid: %08x\n", dword); verb_size = find_verb(dword, &verb); if(!verb_size) { printk(BIOS_DEBUG, "No verb!\n"); return; } printk(BIOS_DEBUG, "verb_size: %d\n", verb_size); /* 3 */ for(i=0; i<verb_size; i++) { send_verb(base,verb[i]); } printk(BIOS_DEBUG, "verb loaded!\n"); }
/* * ----------------------------------------------------------- * Parse one command. * Get tokens from the input stream. * See if the first token is a command name, as it should be, * and if it is, check if optional arguments that follow, * are legal, and if they are, get their values and * save them in a value table, corresponding to this * option. * If any of these conditions are not met, parse error occures. * * Return: * 0 - command parsed OK * EOF - end of file * <> - failure to parse command * ----------------------------------------------------------- */ int parse_cmd(void) { int res, cmd_ind; char *cmd_str; int opt_cnt; int eof, cmd_err; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; opt_cnt = 0; gpqual_root = NULL; func = 0; cmd_err = 0; TREF(parms_cnt) = 0; /* Parameters count */ *cli_err_str = 0; cmd_str = cli_token_buf; /* ------------------------ * If no more tokens exist * ------------------------ */ if (0 == cli_gettoken(&eof)) { if (eof) return (EOF); return (0); } /* ------------------------------ * Find command in command table * ------------------------------ */ if (-1 != (cmd_ind = find_verb(cmd_str))) { gpcmd_qual = cmd_ary[cmd_ind].parms; gpcmd_parm_vals = cmd_ary[cmd_ind].parm_values; gpcmd_verb = &cmd_ary[cmd_ind]; if (gpcmd_qual) clear_parm_vals(gpcmd_qual, TRUE); func = cmd_ary[cmd_ind].func; /* ---------------------- * Parse command options * ---------------------- */ do { res = parse_arg(gpcmd_qual, &eof); if (1 == res) { opt_cnt++; } } while (1 == res); } else { SNPRINTF(cli_err_str, MAX_CLI_ERR_STR, "Unrecognized command: %s", cmd_str); cli_lex_in_ptr->tp = 0; res = -1; } if ((1 > opt_cnt) && (-1 != res) && (VAL_REQ == cmd_ary[cmd_ind].required)) { SNPRINTF(cli_err_str, MAX_CLI_ERR_STR, "Command argument expected, but not found"); res = -1; } /*------------------------------------------------------ * Check that the disallow conditions are met (to allow) *------------------------------------------------------ */ if ((-1 != res) && (FALSE == check_disallow(gpcmd_verb))) res = -1; /* ------------------------------------- * If parse error, display error string * ------------------------------------- */ if (-1 == res) { func = 0; eof = 0; } else return (0); /* ------------------------- * If gettoken returned EOF * ------------------------- */ if (eof) return (EOF); else return (ERR_CLIERR); }