int main(int argc, char **argv) { init_node(argc, argv); outfile = stdout; yyparse(); finish_node(0); return errcnt != 0; }
static void xml_endElement(void *userData, const char *name) { XMLdata **data = (XMLdata**)userData; XMLdata *node = *data; XMLdata *parent = node->parent; finish_node(node); free_node(node); *data = parent; }
/* * finish_device_tree is called once things are running normally * (i.e. with text and data mapped to the address they were linked at). * It traverses the device tree and fills in the name, type, * {n_}addrs and {n_}intrs fields of each node. */ void __init finish_device_tree(void) { unsigned long mem = (unsigned long) klimit; struct device_node *np; /* All newworld pmac machines and CHRPs now use the interrupt tree */ for (np = allnodes; np != NULL; np = np->allnext) { if (get_property(np, "interrupt-parent", 0)) { use_of_interrupt_tree = 1; break; } } if (_machine == _MACH_Pmac && use_of_interrupt_tree) pmac_newworld = 1; #ifdef CONFIG_BOOTX_TEXT if (boot_infos && pmac_newworld) { prom_print("WARNING ! BootX/miBoot booting is not supported on this machine\n"); prom_print(" You should use an Open Firmware bootloader\n"); } #endif /* CONFIG_BOOTX_TEXT */ if (use_of_interrupt_tree) { /* * We want to find out here how many interrupt-controller * nodes there are, and if we are booted from BootX, * we need a pointer to the first (and hopefully only) * such node. But we can't use find_devices here since * np->name has not been set yet. -- paulus */ int n = 0; char *name, *ic; int iclen; for (np = allnodes; np != NULL; np = np->allnext) { ic = get_property(np, "interrupt-controller", &iclen); name = get_property(np, "name", NULL); /* checking iclen makes sure we don't get a false match on /chosen.interrupt_controller */ if ((name != NULL && strcmp(name, "interrupt-controller") == 0) || (ic != NULL && iclen == 0)) { if (n == 0) dflt_interrupt_controller = np; ++n; } } num_interrupt_controllers = n; } mem = finish_node(allnodes, mem, NULL, 1, 1); dev_tree_size = mem - (unsigned long) allnodes; klimit = (char *) mem; }
void dfs(int node,int was_finished[],int was_visited[], int vertices) { SVertex *run; // set the node as visited was_visited[node] = 1; // for every edge coming out of 'node' for(run = list[node].next; run != NULL; run = run->next) { if(!was_visited[run->vert]) { dfs(run->vert,was_finished,was_visited,vertices); } } // insert 'node' in the last position of the array finish_node(node,was_finished,vertices); return ; }
/** * Parse an XML string into a nested list. * The second parameter indicates if body text (text within XML tags) * should show up among the children of the tag or in its own * section. * * See documentation (ext-xml.README) for examples. */ static package parse_xml(const char *data, int bool_stream) { /* * FIXME: Feed expat smaller chunks of the string and * check for task timeout between chunks * */ int decoded_length; const char *decoded; package result; XML_Parser parser = XML_ParserCreate(NULL); XMLdata *root = new_node(NULL, ""); XMLdata *child = root; decoded_length = strlen(data); decoded = data; XML_SetUserData(parser, &child); XML_SetElementHandler(parser, xml_startElement, xml_endElement); if(bool_stream) { XML_SetCharacterDataHandler(parser, xml_streamCharacterDataHandler); } else { XML_SetCharacterDataHandler(parser, xml_characterDataHandler); } if (!XML_Parse(parser, decoded, decoded_length, 1)) { Var r; r.type = TYPE_INT; r.v.num = XML_GetCurrentByteIndex(parser); flush_nodes(child); result = make_raise_pack(E_INVARG, XML_ErrorString(XML_GetErrorCode(parser)), r); } else { finish_node(root); result = make_var_pack(var_ref(root->element.v.list[4].v.list[1])); free_node(root); } XML_ParserFree(parser); return result; }
/** * Begin a block of texture instructions. * Create the necessary indirection. */ static int begin_tex(struct r300_emit_state * emit) { PROG_CODE; if (code->alu.length == emit->node_first_alu && code->tex.length == emit->node_first_tex) { return 1; } if (emit->current_node == 3) { error("Too many texture indirections"); return 0; } if (!finish_node(emit)) return 0; emit->current_node++; emit->node_first_tex = code->tex.length; emit->node_first_alu = code->alu.length; emit->node_flags = 0; return 1; }
/** * Final compilation step: Turn the intermediate radeon_program into * machine-readable instructions. */ void r300BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user) { struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c; struct r300_emit_state emit; struct r300_fragment_program_code *code = &compiler->code->code.r300; unsigned int tex_end; memset(&emit, 0, sizeof(emit)); emit.compiler = compiler; memset(code, 0, sizeof(struct r300_fragment_program_code)); for(struct rc_instruction * inst = compiler->Base.Program.Instructions.Next; inst != &compiler->Base.Program.Instructions && !compiler->Base.Error; inst = inst->Next) { if (inst->Type == RC_INSTRUCTION_NORMAL) { if (inst->U.I.Opcode == RC_OPCODE_BEGIN_TEX) { begin_tex(&emit); continue; } emit_tex(&emit, inst); } else { emit_alu(&emit, &inst->U.P); } } if (code->pixsize >= compiler->Base.max_temp_regs) rc_error(&compiler->Base, "Too many hardware temporaries used.\n"); if (compiler->Base.Error) return; /* Finish the program */ finish_node(&emit); code->config |= emit.current_node; /* FIRST_NODE_HAS_TEX set by finish_node */ /* Set r400 extended instruction fields. These values will be ignored * on r300 cards. */ code->r400_code_offset_ext |= (get_msbs_alu(0) << R400_ALU_OFFSET_MSB_SHIFT) | (get_msbs_alu(code->alu.length - 1) << R400_ALU_SIZE_MSB_SHIFT); tex_end = code->tex.length ? code->tex.length - 1 : 0; code->code_offset = ((0 << R300_PFS_CNTL_ALU_OFFSET_SHIFT) & R300_PFS_CNTL_ALU_OFFSET_MASK) | (((code->alu.length - 1) << R300_PFS_CNTL_ALU_END_SHIFT) & R300_PFS_CNTL_ALU_END_MASK) | ((0 << R300_PFS_CNTL_TEX_OFFSET_SHIFT) & R300_PFS_CNTL_TEX_OFFSET_MASK) | ((tex_end << R300_PFS_CNTL_TEX_END_SHIFT) & R300_PFS_CNTL_TEX_END_MASK) | (get_msbs_tex(0, 5) << R400_TEX_START_MSB_SHIFT) | (get_msbs_tex(tex_end, 6) << R400_TEX_SIZE_MSB_SHIFT) ; if (emit.current_node < 3) { int shift = 3 - emit.current_node; int i; for(i = emit.current_node; i >= 0; --i) code->code_addr[shift + i] = code->code_addr[i]; for(i = 0; i < shift; ++i) code->code_addr[i] = 0; } if (code->pixsize >= R300_PFS_NUM_TEMP_REGS || code->alu.length > R300_PFS_MAX_ALU_INST || code->tex.length > R300_PFS_MAX_TEX_INST) { code->r390_mode = 1; } }
static unsigned long __init finish_node(struct device_node *np, unsigned long mem_start, interpret_func *ifunc, int naddrc, int nsizec) { struct device_node *child; int *ip; np->name = get_property(np, "name", 0); np->type = get_property(np, "device_type", 0); if (!np->name) np->name = "<NULL>"; if (!np->type) np->type = "<NULL>"; /* get the device addresses and interrupts */ if (ifunc != NULL) mem_start = ifunc(np, mem_start, naddrc, nsizec); if (use_of_interrupt_tree) mem_start = finish_node_interrupts(np, mem_start); /* Look for #address-cells and #size-cells properties. */ ip = (int *) get_property(np, "#address-cells", 0); if (ip != NULL) naddrc = *ip; ip = (int *) get_property(np, "#size-cells", 0); if (ip != NULL) nsizec = *ip; if (np->parent == NULL) ifunc = interpret_root_props; else if (np->type == 0) ifunc = NULL; else if (!strcmp(np->type, "pci") || !strcmp(np->type, "vci")) ifunc = interpret_pci_props; else if (!strcmp(np->type, "dbdma")) ifunc = interpret_dbdma_props; else if (!strcmp(np->type, "mac-io") || ifunc == interpret_macio_props) ifunc = interpret_macio_props; else if (!strcmp(np->type, "isa")) ifunc = interpret_isa_props; else if (!strcmp(np->name, "uni-n")) ifunc = interpret_root_props; else if (!((ifunc == interpret_dbdma_props || ifunc == interpret_macio_props) && (!strcmp(np->type, "escc") || !strcmp(np->type, "media-bay")))) ifunc = NULL; /* if we were booted from BootX, convert the full name */ if (boot_infos && strncmp(np->full_name, "Devices:device-tree", 19) == 0) { if (np->full_name[19] == 0) { strcpy(np->full_name, "/"); } else if (np->full_name[19] == ':') { char *p = np->full_name + 19; np->full_name = p; for (; *p; ++p) if (*p == ':') *p = '/'; } } for (child = np->child; child != NULL; child = child->sibling) mem_start = finish_node(child, mem_start, ifunc, naddrc, nsizec); return mem_start; }