int P_gen_code (char *prog_name, Parm_Macro_List *external_list, SymbolTable symbol_table, int file) { int i; int last_file; int et_types; L_curr_pass_name = prog_name; L_parm_file = P_parm_file; PL_symtab = symbol_table; L_load_parameters_aliased (L_parm_file, external_list, "(Lfile", "(file", L_read_parm_file); L_load_parameters (P_parm_file, external_list, "(PtoL", P_read_parm_ptol); L_load_parameters_aliased (L_parm_file, external_list, "(Larchitecture", "(architecture", L_read_parm_arch); L_load_parameters_aliased (L_parm_file, external_list, "(Lfile", "(file", L_read_parm_file); L_load_parameters_aliased (L_parm_file, external_list, "(Lglobal", "(global", L_read_parm_global); L_input_file = F_input; L_output_file = F_output; PLD ("Initializing"); /* * Initialize Lcode symbols */ L_init_symbol (); /* * Create pools for Lcode data structs */ L_setup_alloc_pools (); /* * Initialize intrinsic support. * L_intrinsic_init internally predicated on * the L_intrinsic support enabled flag. */ L_intrinsic_init (); /* * Set up the enviroment */ M_set_machine (L_arch, L_model, L_swarch); M_define_macros (L_macro_symbol_table); M_define_opcode_name (L_opcode_symbol_table); PL_native_int_reg_ctype = M_native_int_register_ctype (); PL_native_int_reg_mtype = M_native_int_register_mtype (); PL_native_int_size = PL_MType_Size(PL_native_int_reg_mtype); PL_native_int_align = PL_MType_Align(PL_native_int_reg_mtype); PL_native_order = /*M_layout_order ()*/ M_LITTLE_ENDIAN; PL_InitTypeSizes (); if (PL_native_order != M_LITTLE_ENDIAN && PL_native_order != M_BIG_ENDIAN) P_punt ("PtoL: Unknown layout ordering"); /* Create/Init data */ L_datalist = L_new_datalist (); L_hash_datalist = L_new_datalist (); L_string_datalist = L_new_datalist (); PL_init_strings (); L_fn = NULL; PSI_SetTable (symbol_table); PSI_SetFlags (STF_READ_ONLY); /* * Process the Files */ PLD ("Processing structure definitions for __impact_data.lc"); /* Handle all structure definitions */ { Key key; L_OUT = NULL; et_types = (ET_TYPE | ET_STRUCT | ET_UNION); PLD ("- Ordering type uses"); PST_OrderTypeUses (symbol_table); PLD ("- Extracting struct, union, and type definitions"); /* Write struct and union definitions and typedefs. */ for (key = PST_GetTableEntryByType (symbol_table, et_types); P_ValidKey (key); key = PST_GetTableEntryByTypeNext (symbol_table, key, et_types)) { SymTabEntry entry = PST_GetSymTabEntry (symbol_table, key); _EntryType e; switch ((e = P_GetSymTabEntryType (entry))) { case ET_TYPE_LOCAL: case ET_TYPE_GLOBAL: break; case ET_STRUCT: { StructDcl struct_dcl = P_GetSymTabEntryStructDcl (entry); PL_gen_lcode_struct (L_datalist, struct_dcl); } break; case ET_UNION: { UnionDcl union_dcl = P_GetSymTabEntryUnionDcl (entry); PL_gen_lcode_union (L_datalist, union_dcl); } break; default: P_punt ("Invalid entry type %d", e); } } PST_ResetOrder (symbol_table); PLD ("- Printing structure definitions"); /* Dump all structure definitions */ L_OUT = L_DOUT = fopen("__impact_data.lc", "w"); assert(L_OUT); PL_print_data(); } PLD ("Processing source files"); last_file = P_GetSymbolTableNumFiles (symbol_table); et_types = (ET_FUNC | ET_VAR_GLOBAL); for (i = 1; i <= last_file; i++) { SymTabEntry entry; Key key; /* JWS 20040507: Shouldn't be necessary to process non-source files */ if (symbol_table->ip_table[i]->file_type != FT_SOURCE) continue; /* JWS 20040507: hack for lib.c inclusion */ /* REK 20040830: stripping directory name if specified. */ if (P_NameCheck (symbol_table->ip_table[i]->source_name, "__impact_lib")) { PLD ("- Skipping %s", symbol_table->ip_table[i]->source_name); continue; } else if (P_NameCheck (symbol_table->ip_table[i]->source_name, "__impact_intrinsic")) { PLD ("- Skipping %s", symbol_table->ip_table[i]->source_name); continue; } { char *name = symbol_table->ip_table[i]->in_name; char *new_name; int len = strlen(name); if (L_OUT && L_OUT != L_DOUT) fclose(L_OUT); PLD ("- Processing file %s", name); new_name = malloc(len + 10); strcpy(new_name, name); /* Write a null over the last . in in_name, then cat the .lc * extension onto it. */ strrchr (new_name, '.')[0] = '\0'; strncat (new_name, ".lc", len); L_OUT = fopen(new_name, "w"); assert(L_OUT); free(new_name); } /* Set up for a new file: clear the string table and * invalidate any open section. */ PL_forget_strings (); PL_invalidate_last_ms (); for (key = PST_GetFileEntryByType (symbol_table, i, et_types); P_ValidKey (key); key = PST_GetFileEntryByTypeNext (symbol_table, key, et_types)) { entry = PST_GetSymTabEntry (symbol_table, key); switch (P_GetSymTabEntryType (entry)) { case ET_FUNC: { FuncDcl func_dcl = P_GetSymTabEntryFuncDcl (entry); Key scope_key = P_GetScopeKey(PST_GetScope(PL_symtab, func_dcl->key)); PL_file_scope = scope_key.file; #if DEBUG_DepL /* * check DepList annotation */ PrintFuncDepInfo (stderr, func_dcl, expr_ext_deplist_idx); #endif /* Create and dump function and data definitions */ if (func_dcl->stmt) { PLD (" - Processing function %s()", func_dcl->name); PL_gen_lcode_func (func_dcl); PLD (" Done"); } PL_print_data(); } break; case ET_VAR_GLOBAL: { VarDcl var_dcl = P_GetSymTabEntryVarDcl (entry); /* Create and dump global data definitions */ PL_gen_lcode_var (L_datalist, var_dcl); PL_print_data(); } break; default: break; } } } PLD ("Cleaning up"); /* Free up data */ L_delete_datalist (L_datalist); L_delete_datalist (L_hash_datalist); L_delete_datalist (L_string_datalist); L_datalist = L_hash_datalist = L_string_datalist = NULL; PL_deinit_strings (); PLD ("Done!"); return (num_func); }
/* Detect all SSAs attached to the machine. To be fast, do it on all online FC channels at the same time. */ __initfunc(int pluto_detect(Scsi_Host_Template *tpnt)) { int i, retry, nplutos; fc_channel *fc; Scsi_Device dev; tpnt->proc_dir = &proc_scsi_pluto; fcscount = 0; for_each_online_fc_channel(fc) fcscount++; PLND(("%d channels online\n", fcscount)) if (!fcscount) { #if defined(MODULE) && defined(CONFIG_FC4_SOC_MODULE) && defined(CONFIG_KMOD) request_module("soc"); for_each_online_fc_channel(fc) fcscount++; if (!fcscount) #endif return 0; } fcs = (struct ctrl_inquiry *) scsi_init_malloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); if (!fcs) { printk ("PLUTO: Not enough memory to probe\n"); return 0; } memset (fcs, 0, sizeof (struct ctrl_inquiry) * fcscount); memset (&dev, 0, sizeof(dev)); atomic_set (&fcss, fcscount); fc_timer.function = pluto_detect_timeout; i = 0; for_each_online_fc_channel(fc) { Scsi_Cmnd *SCpnt; struct Scsi_Host *host; struct pluto *pluto; if (i == fcscount) break; PLD(("trying to find SSA\n")) /* If this is already registered to some other SCSI host, then it cannot be pluto */ if (fc->scsi_name[0]) continue; memcpy (fc->scsi_name, "SSA", 4); fcs[i].fc = fc; fc->can_queue = PLUTO_CAN_QUEUE; fc->rsp_size = 64; fc->encode_addr = pluto_encode_addr; fc->fcp_register(fc, TYPE_SCSI_FCP, 0); SCpnt = &(fcs[i].cmd); host = &(fcs[i].host); pluto = (struct pluto *)host->hostdata; pluto->fc = fc; SCpnt->host = host; SCpnt->cmnd[0] = INQUIRY; SCpnt->cmnd[4] = 255; /* FC layer requires this, so that SCpnt->device->tagged_supported is initially 0 */ SCpnt->device = &dev; SCpnt->cmd_len = COMMAND_SIZE(INQUIRY); SCpnt->request.rq_status = RQ_SCSI_BUSY; SCpnt->done = pluto_detect_done; SCpnt->bufflen = 256; SCpnt->buffer = fcs[i].inquiry; SCpnt->request_bufflen = 256; SCpnt->request_buffer = fcs[i].inquiry; PLD(("set up %d %08lx\n", i, (long)SCpnt)) i++; } for (retry = 0; retry < 5; retry++) { for (i = 0; i < fcscount; i++) { if (!fcs[i].fc) break; if (fcs[i].cmd.request.rq_status != RQ_SCSI_DONE) { disable_irq(fcs[i].fc->irq); PLND(("queuecommand %d %d\n", retry, i)) fcp_scsi_queuecommand (&(fcs[i].cmd), pluto_detect_scsi_done); enable_irq(fcs[i].fc->irq); } } fc_timer.expires = jiffies + 10 * HZ; add_timer(&fc_timer); down(&fc_sem); PLND(("Woken up\n")) if (!atomic_read(&fcss)) break; /* All fc channels have answered us */ } del_timer(&fc_timer); PLND(("Finished search\n")) for (i = 0, nplutos = 0; i < fcscount; i++) { Scsi_Cmnd *SCpnt; if (!(fc = fcs[i].fc)) break; SCpnt = &(fcs[i].cmd); /* Let FC mid-level free allocated resources */ SCpnt->done (SCpnt); if (!SCpnt->result) { struct pluto_inquiry *inq; struct pluto *pluto; struct Scsi_Host *host; inq = (struct pluto_inquiry *)fcs[i].inquiry; if ((inq->dtype & 0x1f) == TYPE_PROCESSOR && !strncmp (inq->vendor_id, "SUN", 3) && !strncmp (inq->product_id, "SSA", 3)) { char *p; long *ages; ages = kmalloc (((inq->channels + 1) * inq->targets) * sizeof(long), GFP_KERNEL); if (!ages) continue; host = scsi_register (tpnt, sizeof (struct pluto)); if (!host) panic ("Cannot register PLUTO host\n"); nplutos++; if (fc->module) __MOD_INC_USE_COUNT(fc->module); pluto = (struct pluto *)host->hostdata; host->max_id = inq->targets; host->max_channel = inq->channels; host->irq = fc->irq; host->select_queue_depths = pluto_select_queue_depths; fc->channels = inq->channels + 1; fc->targets = inq->targets; fc->ages = ages; memset (ages, 0, ((inq->channels + 1) * inq->targets) * sizeof(long)); pluto->fc = fc; memcpy (pluto->rev_str, inq->revision, 4); pluto->rev_str[4] = 0; p = strchr (pluto->rev_str, ' '); if (p) *p = 0; memcpy (pluto->fw_rev_str, inq->fw_revision, 4); pluto->fw_rev_str[4] = 0; p = strchr (pluto->fw_rev_str, ' '); if (p) *p = 0; memcpy (pluto->serial_str, inq->serial, 12); pluto->serial_str[12] = 0; p = strchr (pluto->serial_str, ' '); if (p) *p = 0; PLD(("Found SSA rev %s fw rev %s serial %s %dx%d\n", pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, host->max_channel, host->max_id)) } else fc->fcp_register(fc, TYPE_SCSI_FCP, 1); } else