highlevel.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * IEEE 1394 for Linux
  3. *
  4. * Copyright (C) 1999 Andreas E. Bombe
  5. *
  6. * This code is licensed under the GPL. See the file COPYING in the root
  7. * directory of the kernel sources for details.
  8. *
  9. *
  10. * Contributions:
  11. *
  12. * Christian Toegel <christian.toegel@gmx.at>
  13. * unregister address space
  14. *
  15. * Manfred Weihs <weihs@ict.tuwien.ac.at>
  16. * unregister address space
  17. *
  18. */
  19. #include <linux/slab.h>
  20. #include <linux/list.h>
  21. #include <linux/bitops.h>
  22. #include "ieee1394.h"
  23. #include "ieee1394_types.h"
  24. #include "hosts.h"
  25. #include "ieee1394_core.h"
  26. #include "highlevel.h"
  27. #include "nodemgr.h"
  28. struct hl_host_info {
  29. struct list_head list;
  30. struct hpsb_host *host;
  31. size_t size;
  32. unsigned long key;
  33. void *data;
  34. };
  35. static LIST_HEAD(hl_drivers);
  36. static DECLARE_RWSEM(hl_drivers_sem);
  37. static LIST_HEAD(hl_irqs);
  38. static DEFINE_RWLOCK(hl_irqs_lock);
  39. static DEFINE_RWLOCK(addr_space_lock);
  40. static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
  41. struct hpsb_host *host)
  42. {
  43. struct hl_host_info *hi = NULL;
  44. if (!hl || !host)
  45. return NULL;
  46. read_lock(&hl->host_info_lock);
  47. list_for_each_entry(hi, &hl->host_info_list, list) {
  48. if (hi->host == host) {
  49. read_unlock(&hl->host_info_lock);
  50. return hi;
  51. }
  52. }
  53. read_unlock(&hl->host_info_lock);
  54. return NULL;
  55. }
  56. /**
  57. * hpsb_get_hostinfo - retrieve a hostinfo pointer bound to this driver/host
  58. *
  59. * Returns a per @host and @hl driver data structure that was previously stored
  60. * by hpsb_create_hostinfo.
  61. */
  62. void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  63. {
  64. struct hl_host_info *hi = hl_get_hostinfo(hl, host);
  65. return hi ? hi->data : NULL;
  66. }
  67. /**
  68. * hpsb_create_hostinfo - allocate a hostinfo pointer bound to this driver/host
  69. *
  70. * Allocate a hostinfo pointer backed by memory with @data_size and bind it to
  71. * to this @hl driver and @host. If @data_size is zero, then the return here is
  72. * only valid for error checking.
  73. */
  74. void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  75. size_t data_size)
  76. {
  77. struct hl_host_info *hi;
  78. void *data;
  79. unsigned long flags;
  80. hi = hl_get_hostinfo(hl, host);
  81. if (hi) {
  82. HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already"
  83. " exists", hl->name);
  84. return NULL;
  85. }
  86. hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
  87. if (!hi)
  88. return NULL;
  89. if (data_size) {
  90. data = hi->data = hi + 1;
  91. hi->size = data_size;
  92. } else
  93. data = hi;
  94. hi->host = host;
  95. write_lock_irqsave(&hl->host_info_lock, flags);
  96. list_add_tail(&hi->list, &hl->host_info_list);
  97. write_unlock_irqrestore(&hl->host_info_lock, flags);
  98. return data;
  99. }
  100. /**
  101. * hpsb_set_hostinfo - set the hostinfo pointer to something useful
  102. *
  103. * Usually follows a call to hpsb_create_hostinfo, where the size is 0.
  104. */
  105. int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  106. void *data)
  107. {
  108. struct hl_host_info *hi;
  109. hi = hl_get_hostinfo(hl, host);
  110. if (hi) {
  111. if (!hi->size && !hi->data) {
  112. hi->data = data;
  113. return 0;
  114. } else
  115. HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo "
  116. "already has data", hl->name);
  117. } else
  118. HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
  119. hl->name);
  120. return -EINVAL;
  121. }
  122. /**
  123. * hpsb_destroy_hostinfo - free and remove a hostinfo pointer
  124. *
  125. * Free and remove the hostinfo pointer bound to this @hl driver and @host.
  126. */
  127. void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  128. {
  129. struct hl_host_info *hi;
  130. hi = hl_get_hostinfo(hl, host);
  131. if (hi) {
  132. unsigned long flags;
  133. write_lock_irqsave(&hl->host_info_lock, flags);
  134. list_del(&hi->list);
  135. write_unlock_irqrestore(&hl->host_info_lock, flags);
  136. kfree(hi);
  137. }
  138. return;
  139. }
  140. /**
  141. * hpsb_set_hostinfo_key - set an alternate lookup key for an hostinfo
  142. *
  143. * Sets an alternate lookup key for the hostinfo bound to this @hl driver and
  144. * @host.
  145. */
  146. void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host,
  147. unsigned long key)
  148. {
  149. struct hl_host_info *hi;
  150. hi = hl_get_hostinfo(hl, host);
  151. if (hi)
  152. hi->key = key;
  153. return;
  154. }
  155. /**
  156. * hpsb_get_hostinfo_bykey - retrieve a hostinfo pointer by its alternate key
  157. */
  158. void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
  159. {
  160. struct hl_host_info *hi;
  161. void *data = NULL;
  162. if (!hl)
  163. return NULL;
  164. read_lock(&hl->host_info_lock);
  165. list_for_each_entry(hi, &hl->host_info_list, list) {
  166. if (hi->key == key) {
  167. data = hi->data;
  168. break;
  169. }
  170. }
  171. read_unlock(&hl->host_info_lock);
  172. return data;
  173. }
  174. static int highlevel_for_each_host_reg(struct hpsb_host *host, void *__data)
  175. {
  176. struct hpsb_highlevel *hl = __data;
  177. hl->add_host(host);
  178. if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
  179. HPSB_ERR("Failed to generate Configuration ROM image for host "
  180. "%s-%d", hl->name, host->id);
  181. return 0;
  182. }
  183. /**
  184. * hpsb_register_highlevel - register highlevel driver
  185. *
  186. * The name pointer in @hl has to stay valid at all times because the string is
  187. * not copied.
  188. */
  189. void hpsb_register_highlevel(struct hpsb_highlevel *hl)
  190. {
  191. unsigned long flags;
  192. hpsb_init_highlevel(hl);
  193. INIT_LIST_HEAD(&hl->addr_list);
  194. down_write(&hl_drivers_sem);
  195. list_add_tail(&hl->hl_list, &hl_drivers);
  196. up_write(&hl_drivers_sem);
  197. write_lock_irqsave(&hl_irqs_lock, flags);
  198. list_add_tail(&hl->irq_list, &hl_irqs);
  199. write_unlock_irqrestore(&hl_irqs_lock, flags);
  200. if (hl->add_host)
  201. nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
  202. return;
  203. }
  204. static void __delete_addr(struct hpsb_address_serve *as)
  205. {
  206. list_del(&as->host_list);
  207. list_del(&as->hl_list);
  208. kfree(as);
  209. }
  210. static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
  211. int update_cr)
  212. {
  213. unsigned long flags;
  214. struct list_head *lh, *next;
  215. struct hpsb_address_serve *as;
  216. /* First, let the highlevel driver unreg */
  217. if (hl->remove_host)
  218. hl->remove_host(host);
  219. /* Remove any addresses that are matched for this highlevel driver
  220. * and this particular host. */
  221. write_lock_irqsave(&addr_space_lock, flags);
  222. list_for_each_safe (lh, next, &hl->addr_list) {
  223. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  224. if (as->host == host)
  225. __delete_addr(as);
  226. }
  227. write_unlock_irqrestore(&addr_space_lock, flags);
  228. /* Now update the config-rom to reflect anything removed by the
  229. * highlevel driver. */
  230. if (update_cr && host->update_config_rom &&
  231. hpsb_update_config_rom_image(host) < 0)
  232. HPSB_ERR("Failed to generate Configuration ROM image for host "
  233. "%s-%d", hl->name, host->id);
  234. /* Finally remove all the host info associated between these two. */
  235. hpsb_destroy_hostinfo(hl, host);
  236. }
  237. static int highlevel_for_each_host_unreg(struct hpsb_host *host, void *__data)
  238. {
  239. struct hpsb_highlevel *hl = __data;
  240. __unregister_host(hl, host, 1);
  241. return 0;
  242. }
  243. /**
  244. * hpsb_unregister_highlevel - unregister highlevel driver
  245. */
  246. void hpsb_unregister_highlevel(struct hpsb_highlevel *hl)
  247. {
  248. unsigned long flags;
  249. write_lock_irqsave(&hl_irqs_lock, flags);
  250. list_del(&hl->irq_list);
  251. write_unlock_irqrestore(&hl_irqs_lock, flags);
  252. down_write(&hl_drivers_sem);
  253. list_del(&hl->hl_list);
  254. up_write(&hl_drivers_sem);
  255. nodemgr_for_each_host(hl, highlevel_for_each_host_unreg);
  256. }
  257. /**
  258. * hpsb_allocate_and_register_addrspace - alloc' and reg' a host address space
  259. *
  260. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  261. * @end points to the first address behind the handled addresses. This
  262. * function can be called multiple times for a single hpsb_highlevel @hl to
  263. * implement sparse register sets. The requested region must not overlap any
  264. * previously allocated region, otherwise registering will fail.
  265. *
  266. * It returns true for successful allocation. Address spaces can be
  267. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  268. * are automatically deallocated together with the hpsb_highlevel @hl.
  269. */
  270. u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
  271. struct hpsb_host *host,
  272. struct hpsb_address_ops *ops,
  273. u64 size, u64 alignment,
  274. u64 start, u64 end)
  275. {
  276. struct hpsb_address_serve *as, *a1, *a2;
  277. struct list_head *entry;
  278. u64 retval = CSR1212_INVALID_ADDR_SPACE;
  279. unsigned long flags;
  280. u64 align_mask = ~(alignment - 1);
  281. if ((alignment & 3) || (alignment > 0x800000000000ULL) ||
  282. (hweight64(alignment) != 1)) {
  283. HPSB_ERR("%s called with invalid alignment: 0x%048llx",
  284. __func__, (unsigned long long)alignment);
  285. return retval;
  286. }
  287. /* default range,
  288. * avoids controller's posted write area (see OHCI 1.1 clause 1.5) */
  289. if (start == CSR1212_INVALID_ADDR_SPACE &&
  290. end == CSR1212_INVALID_ADDR_SPACE) {
  291. start = host->middle_addr_space;
  292. end = CSR1212_ALL_SPACE_END;
  293. }
  294. if (((start|end) & ~align_mask) || (start >= end) ||
  295. (end > CSR1212_ALL_SPACE_END)) {
  296. HPSB_ERR("%s called with invalid addresses "
  297. "(start = %012Lx end = %012Lx)", __func__,
  298. (unsigned long long)start,(unsigned long long)end);
  299. return retval;
  300. }
  301. as = kmalloc(sizeof(*as), GFP_KERNEL);
  302. if (!as)
  303. return retval;
  304. INIT_LIST_HEAD(&as->host_list);
  305. INIT_LIST_HEAD(&as->hl_list);
  306. as->op = ops;
  307. as->host = host;
  308. write_lock_irqsave(&addr_space_lock, flags);
  309. list_for_each(entry, &host->addr_space) {
  310. u64 a1sa, a1ea;
  311. u64 a2sa, a2ea;
  312. a1 = list_entry(entry, struct hpsb_address_serve, host_list);
  313. a2 = list_entry(entry->next, struct hpsb_address_serve,
  314. host_list);
  315. a1sa = a1->start & align_mask;
  316. a1ea = (a1->end + alignment -1) & align_mask;
  317. a2sa = a2->start & align_mask;
  318. a2ea = (a2->end + alignment -1) & align_mask;
  319. if ((a2sa - a1ea >= size) && (a2sa - start >= size) &&
  320. (a2sa > start)) {
  321. as->start = max(start, a1ea);
  322. as->end = as->start + size;
  323. list_add(&as->host_list, entry);
  324. list_add_tail(&as->hl_list, &hl->addr_list);
  325. retval = as->start;
  326. break;
  327. }
  328. }
  329. write_unlock_irqrestore(&addr_space_lock, flags);
  330. if (retval == CSR1212_INVALID_ADDR_SPACE)
  331. kfree(as);
  332. return retval;
  333. }
  334. /**
  335. * hpsb_register_addrspace - register a host address space
  336. *
  337. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  338. * @end points to the first address behind the handled addresses. This
  339. * function can be called multiple times for a single hpsb_highlevel @hl to
  340. * implement sparse register sets. The requested region must not overlap any
  341. * previously allocated region, otherwise registering will fail.
  342. *
  343. * It returns true for successful allocation. Address spaces can be
  344. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  345. * are automatically deallocated together with the hpsb_highlevel @hl.
  346. */
  347. int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  348. struct hpsb_address_ops *ops, u64 start, u64 end)
  349. {
  350. struct hpsb_address_serve *as;
  351. struct list_head *lh;
  352. int retval = 0;
  353. unsigned long flags;
  354. if (((start|end) & 3) || (start >= end) ||
  355. (end > CSR1212_ALL_SPACE_END)) {
  356. HPSB_ERR("%s called with invalid addresses", __func__);
  357. return 0;
  358. }
  359. as = kmalloc(sizeof(*as), GFP_ATOMIC);
  360. if (!as)
  361. return 0;
  362. INIT_LIST_HEAD(&as->host_list);
  363. INIT_LIST_HEAD(&as->hl_list);
  364. as->op = ops;
  365. as->start = start;
  366. as->end = end;
  367. as->host = host;
  368. write_lock_irqsave(&addr_space_lock, flags);
  369. list_for_each(lh, &host->addr_space) {
  370. struct hpsb_address_serve *as_this =
  371. list_entry(lh, struct hpsb_address_serve, host_list);
  372. struct hpsb_address_serve *as_next =
  373. list_entry(lh->next, struct hpsb_address_serve,
  374. host_list);
  375. if (as_this->end > as->start)
  376. break;
  377. if (as_next->start >= as->end) {
  378. list_add(&as->host_list, lh);
  379. list_add_tail(&as->hl_list, &hl->addr_list);
  380. retval = 1;
  381. break;
  382. }
  383. }
  384. write_unlock_irqrestore(&addr_space_lock, flags);
  385. if (retval == 0)
  386. kfree(as);
  387. return retval;
  388. }
  389. int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  390. u64 start)
  391. {
  392. int retval = 0;
  393. struct hpsb_address_serve *as;
  394. struct list_head *lh, *next;
  395. unsigned long flags;
  396. write_lock_irqsave(&addr_space_lock, flags);
  397. list_for_each_safe (lh, next, &hl->addr_list) {
  398. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  399. if (as->start == start && as->host == host) {
  400. __delete_addr(as);
  401. retval = 1;
  402. break;
  403. }
  404. }
  405. write_unlock_irqrestore(&addr_space_lock, flags);
  406. return retval;
  407. }
  408. static struct hpsb_address_ops dummy_ops;
  409. /* dummy address spaces as lower and upper bounds of the host's a.s. list */
  410. static void init_hpsb_highlevel(struct hpsb_host *host)
  411. {
  412. INIT_LIST_HEAD(&host->dummy_zero_addr.host_list);
  413. INIT_LIST_HEAD(&host->dummy_zero_addr.hl_list);
  414. INIT_LIST_HEAD(&host->dummy_max_addr.host_list);
  415. INIT_LIST_HEAD(&host->dummy_max_addr.hl_list);
  416. host->dummy_zero_addr.op = host->dummy_max_addr.op = &dummy_ops;
  417. host->dummy_zero_addr.start = host->dummy_zero_addr.end = 0;
  418. host->dummy_max_addr.start = host->dummy_max_addr.end = ((u64) 1) << 48;
  419. list_add_tail(&host->dummy_zero_addr.host_list, &host->addr_space);
  420. list_add_tail(&host->dummy_max_addr.host_list, &host->addr_space);
  421. }
  422. void highlevel_add_host(struct hpsb_host *host)
  423. {
  424. struct hpsb_highlevel *hl;
  425. init_hpsb_highlevel(host);
  426. down_read(&hl_drivers_sem);
  427. list_for_each_entry(hl, &hl_drivers, hl_list) {
  428. if (hl->add_host)
  429. hl->add_host(host);
  430. }
  431. up_read(&hl_drivers_sem);
  432. if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
  433. HPSB_ERR("Failed to generate Configuration ROM image for host "
  434. "%s-%d", hl->name, host->id);
  435. }
  436. void highlevel_remove_host(struct hpsb_host *host)
  437. {
  438. struct hpsb_highlevel *hl;
  439. down_read(&hl_drivers_sem);
  440. list_for_each_entry(hl, &hl_drivers, hl_list)
  441. __unregister_host(hl, host, 0);
  442. up_read(&hl_drivers_sem);
  443. }
  444. void highlevel_host_reset(struct hpsb_host *host)
  445. {
  446. unsigned long flags;
  447. struct hpsb_highlevel *hl;
  448. read_lock_irqsave(&hl_irqs_lock, flags);
  449. list_for_each_entry(hl, &hl_irqs, irq_list) {
  450. if (hl->host_reset)
  451. hl->host_reset(host);
  452. }
  453. read_unlock_irqrestore(&hl_irqs_lock, flags);
  454. }
  455. void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
  456. void *data, size_t length)
  457. {
  458. unsigned long flags;
  459. struct hpsb_highlevel *hl;
  460. int cts = ((quadlet_t *)data)[0] >> 4;
  461. read_lock_irqsave(&hl_irqs_lock, flags);
  462. list_for_each_entry(hl, &hl_irqs, irq_list) {
  463. if (hl->fcp_request)
  464. hl->fcp_request(host, nodeid, direction, cts, data,
  465. length);
  466. }
  467. read_unlock_irqrestore(&hl_irqs_lock, flags);
  468. }
  469. /*
  470. * highlevel_read, highlevel_write, highlevel_lock, highlevel_lock64:
  471. *
  472. * These functions are called to handle transactions. They are called when a
  473. * packet arrives. The flags argument contains the second word of the first
  474. * header quadlet of the incoming packet (containing transaction label, retry
  475. * code, transaction code and priority). These functions either return a
  476. * response code or a negative number. In the first case a response will be
  477. * generated. In the latter case, no response will be sent and the driver which
  478. * handled the request will send the response itself.
  479. */
  480. int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr,
  481. unsigned int length, u16 flags)
  482. {
  483. struct hpsb_address_serve *as;
  484. unsigned int partlength;
  485. int rcode = RCODE_ADDRESS_ERROR;
  486. read_lock(&addr_space_lock);
  487. list_for_each_entry(as, &host->addr_space, host_list) {
  488. if (as->start > addr)
  489. break;
  490. if (as->end > addr) {
  491. partlength = min(as->end - addr, (u64) length);
  492. if (as->op->read)
  493. rcode = as->op->read(host, nodeid, data,
  494. addr, partlength, flags);
  495. else
  496. rcode = RCODE_TYPE_ERROR;
  497. data += partlength;
  498. length -= partlength;
  499. addr += partlength;
  500. if ((rcode != RCODE_COMPLETE) || !length)
  501. break;
  502. }
  503. }
  504. read_unlock(&addr_space_lock);
  505. if (length && (rcode == RCODE_COMPLETE))
  506. rcode = RCODE_ADDRESS_ERROR;
  507. return rcode;
  508. }
  509. int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data,
  510. u64 addr, unsigned int length, u16 flags)
  511. {
  512. struct hpsb_address_serve *as;
  513. unsigned int partlength;
  514. int rcode = RCODE_ADDRESS_ERROR;
  515. read_lock(&addr_space_lock);
  516. list_for_each_entry(as, &host->addr_space, host_list) {
  517. if (as->start > addr)
  518. break;
  519. if (as->end > addr) {
  520. partlength = min(as->end - addr, (u64) length);
  521. if (as->op->write)
  522. rcode = as->op->write(host, nodeid, destid,
  523. data, addr, partlength,
  524. flags);
  525. else
  526. rcode = RCODE_TYPE_ERROR;
  527. data += partlength;
  528. length -= partlength;
  529. addr += partlength;
  530. if ((rcode != RCODE_COMPLETE) || !length)
  531. break;
  532. }
  533. }
  534. read_unlock(&addr_space_lock);
  535. if (length && (rcode == RCODE_COMPLETE))
  536. rcode = RCODE_ADDRESS_ERROR;
  537. return rcode;
  538. }
  539. int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
  540. u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
  541. u16 flags)
  542. {
  543. struct hpsb_address_serve *as;
  544. int rcode = RCODE_ADDRESS_ERROR;
  545. read_lock(&addr_space_lock);
  546. list_for_each_entry(as, &host->addr_space, host_list) {
  547. if (as->start > addr)
  548. break;
  549. if (as->end > addr) {
  550. if (as->op->lock)
  551. rcode = as->op->lock(host, nodeid, store, addr,
  552. data, arg, ext_tcode,
  553. flags);
  554. else
  555. rcode = RCODE_TYPE_ERROR;
  556. break;
  557. }
  558. }
  559. read_unlock(&addr_space_lock);
  560. return rcode;
  561. }
  562. int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
  563. u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
  564. u16 flags)
  565. {
  566. struct hpsb_address_serve *as;
  567. int rcode = RCODE_ADDRESS_ERROR;
  568. read_lock(&addr_space_lock);
  569. list_for_each_entry(as, &host->addr_space, host_list) {
  570. if (as->start > addr)
  571. break;
  572. if (as->end > addr) {
  573. if (as->op->lock64)
  574. rcode = as->op->lock64(host, nodeid, store,
  575. addr, data, arg,
  576. ext_tcode, flags);
  577. else
  578. rcode = RCODE_TYPE_ERROR;
  579. break;
  580. }
  581. }
  582. read_unlock(&addr_space_lock);
  583. return rcode;
  584. }