/* * mspec_init * * Called at boot time to initialize the mspec facility. */ static int __init mspec_init(void) { int ret; int nid; /* * The fetchop device only works on SN2 hardware, uncached and cached * memory drivers should both be valid on all ia64 hardware */ #ifdef CONFIG_SGI_SN if (ia64_platform_is("sn2")) { is_sn2 = 1; if (is_shub2()) { ret = -ENOMEM; for_each_node_state(nid, N_ONLINE) { int actual_nid; int nasid; unsigned long phys; scratch_page[nid] = uncached_alloc_page(nid, 1); if (scratch_page[nid] == 0) goto free_scratch_pages; phys = __pa(scratch_page[nid]); nasid = get_node_number(phys); actual_nid = nasid_to_cnodeid(nasid); if (actual_nid != nid) goto free_scratch_pages; } }
static inline int mspec_zero_block(unsigned long addr, int len) { int status; if (is_sn2) { if (is_shub2()) { int nid; void *p; int i; nid = nasid_to_cnodeid(get_node_number(__pa(addr))); p = (void *)TO_AMO(scratch_page[nid]); for (i=0; i < SH2_AMO_CACHE_ENTRIES; i++) { FETCHOP_LOAD_OP(p, FETCHOP_LOAD); p += FETCHOP_VAR_SIZE; } } status = bte_copy(0, addr & ~__IA64_UNCACHED_OFFSET, len, BTE_WACQUIRE | BTE_ZERO_FILL, NULL); } else { memset((char *) addr, 0, len); status = 0; } return status; }
int main() { t_btree *root; t_btree *root1; t_btree *root2; t_btree *root3; t_btree *root4; t_btree *root5; root = btree_create_node("0"); root1 = btree_create_node("1"); root2 = btree_create_node("2"); root3 = btree_create_node("3"); root4 = btree_create_node("4"); root5 = btree_create_node("5"); root3->left = root2; root2->left = root1; root1->left = root; root3->right = root5; root5->left = root4; //printf("%d", btree_level_count(root3)); printf("%d\n",get_node_number(root3, 0)); return(0); }
// the UDP server API int udp_server(char *msg,int sd,char *from_node) { unsigned int numBytes, cliLen; struct sockaddr_in cliAddr; memset(msg,0x0,MAX_NLP_DATA_SIZE+NLP_HEADER_SIZE); /* receive message */ cliLen = sizeof(cliAddr); numBytes = recvfrom(sd, msg, MAX_NLP_DATA_SIZE+NLP_HEADER_SIZE, 0,(struct sockaddr *) &cliAddr, &cliLen); if(numBytes < 0) { return FAIL; } *from_node = (char)get_node_number(inet_ntoa(cliAddr.sin_addr)); return numBytes; }
/* * mspec_init * * Called at boot time to initialize the mspec facility. */ static int __init mspec_init(void) { int ret; int nid; /* * The fetchop device only works on SN2 hardware, uncached and cached * memory drivers should both be valid on all ia64 hardware */ #ifdef CONFIG_SGI_SN if (ia64_platform_is("sn2")) { is_sn2 = 1; if (is_shub2()) { ret = -ENOMEM; for_each_online_node(nid) { int actual_nid; int nasid; unsigned long phys; scratch_page[nid] = uncached_alloc_page(nid); if (scratch_page[nid] == 0) goto free_scratch_pages; phys = __pa(scratch_page[nid]); nasid = get_node_number(phys); actual_nid = nasid_to_cnodeid(nasid); if (actual_nid != nid) goto free_scratch_pages; } } ret = misc_register(&fetchop_miscdev); if (ret) { printk(KERN_ERR "%s: failed to register device %i\n", FETCHOP_ID, ret); goto free_scratch_pages; } }