int lv1_stor_wrapper_open(u64 dev_id, void *dma_buf, u64 dma_buf_lpar_addr, u64 dma_size_log, lv1_stor_wrapper_var *stor_var) { u64 dma_bus_addr, v2; int result; result = map_dma_mem(STOR_BUS_ID, dev_id, (void *)dma_buf_lpar_addr, (1<<dma_size_log), &dma_bus_addr); if (result != 0) return result; result = lv1_get_repository_node_value(PS3_LPAR_ID_PME, FIELD_FIRST("bus", STOR_BUS_ID), FIELD("dev", dev_id), FIELD("blk_size", 0), 0, &stor_var->block_size, &v2); if (result != 0) { unmap_dma_mem(STOR_BUS_ID, dev_id, dma_bus_addr, dma_size_log); return result; } stor_var->dev_id = dev_id; stor_var->dma = dma_buf; stor_var->dma_lpar_addr = dma_buf_lpar_addr; stor_var->dma_size_log = dma_size_log; stor_var->dma_bus_addr = dma_bus_addr; return 0; }
static void gelic_debug_init(void) { s64 result; u64 v2; u64 mac; u64 vlan_id; result = lv1_open_device(GELIC_BUS_ID, GELIC_DEVICE_ID, 0); if (result) lv1_panic(0); map_dma_mem(GELIC_BUS_ID, GELIC_DEVICE_ID, &dbg, sizeof(dbg), &bus_addr); memset(&dbg, 0, sizeof(dbg)); dbg.descr.buf_addr = bus_addr + offsetof(struct debug_block, pkt); wmb(); result = lv1_net_control(GELIC_BUS_ID, GELIC_DEVICE_ID, GELIC_LV1_GET_MAC_ADDRESS, 0, 0, 0, &mac, &v2); if (result) lv1_panic(0); mac <<= 16; h_eth = (struct ethhdr *)dbg.pkt; memset(&h_eth->dest, 0xff, 6); memcpy(&h_eth->src, &mac, 6); header_size = sizeof(struct ethhdr); result = lv1_net_control(GELIC_BUS_ID, GELIC_DEVICE_ID, GELIC_LV1_GET_VLAN_ID, GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0, &vlan_id, &v2); if (!result) { h_eth->type = 0x8100; header_size += sizeof(struct vlantag); h_vlan = (struct vlantag *)(h_eth + 1); h_vlan->vlan = vlan_id; h_vlan->subtype = 0x0800; h_ip = (struct iphdr *)(h_vlan + 1); } else { h_eth->type = 0x0800; h_ip = (struct iphdr *)(h_eth + 1); } header_size += sizeof(struct iphdr); h_ip->ver_len = 0x45; h_ip->ttl = 10; h_ip->proto = 0x11; h_ip->src = 0x00000000; h_ip->dest = 0xffffffff; header_size += sizeof(struct udphdr); h_udp = (struct udphdr *)(h_ip + 1); h_udp->src = GELIC_DEBUG_PORT; h_udp->dest = GELIC_DEBUG_PORT; pmsgc = pmsg = (char *)(h_udp + 1); }
s64 debug_init(void) { s64 result; u64 v2; result = find_device_by_type(DEV_TYPE_ETH, 0, &bus_id, &dev_id, NULL); if (result) return result; result = map_dma_mem(bus_id, dev_id, dbg, sizeof(struct debug_block), &bus_addr); if (result) return result; memset(dbg, 0, sizeof(struct debug_block)); dbg->descr.buf_addr = bus_addr + offsetof(struct debug_block, pkt); u64 mac; result = lv1_net_control(bus_id, dev_id, GELIC_LV1_GET_MAC_ADDRESS, 0, 0, 0, &mac, &v2); if (result) return result; mac <<= 16; h_eth = (struct ethhdr*)dbg->pkt; memset(&h_eth->dest, 0xff, 6); memcpy(&h_eth->src, &mac, 6); header_size = sizeof(struct ethhdr); u64 vlan_id; result = lv1_net_control(bus_id, dev_id, GELIC_LV1_GET_VLAN_ID, \ GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0, &vlan_id, &v2); if (result == 0) { h_eth->type = 0x8100; header_size += sizeof(struct vlantag); h_vlan = (struct vlantag*)(h_eth+1); h_vlan->vlan = vlan_id; h_vlan->subtype = 0x0800; h_ip = (struct iphdr*)(h_vlan+1); } else { h_eth->type = 0x0800; h_ip = (struct iphdr*)(h_eth+1); } header_size += sizeof(struct iphdr); h_ip->ver_len = 0x45; h_ip->ttl = 10; h_ip->proto = 0x11; h_ip->src = 0x00000000; h_ip->dest = 0xffffffff; header_size += sizeof(struct udphdr); h_udp = (struct udphdr*)(h_ip+1); h_udp->src = DEBUG_PORT; h_udp->dest = DEBUG_PORT; pmsg = (char*)(h_udp+1); debug_initialized = 1; return 0; }