- unsigned long *pt = &ptable[1];
- unsigned long tmp;
-
- if (ptable_init() < 0) {
- fprintf(stderr, "Could not load the ptable\n");
- return -1;
- }
-
- while (*pt != PTABLE_END) {
- if (*pt == key) {
- tmp = wlc_kmem_read(pt[1]);
-
- if (tmp == pt[2])
- *val = 0xffffffff;
- else
- *val = tmp;
-
- return 0;
- }
- pt += 3;
- }
-
- return -1;
-}
-
-static int wlc_patcher_setval(unsigned long key, unsigned long val)
-{
- unsigned long *pt = &ptable[1];
-
- if (ptable_init() < 0) {
- fprintf(stderr, "Could not load the ptable\n");
- return -1;
- }
-
- if (val != 0xffffffff)
- val = (pt[2] & ~(0xffff)) | (val & 0xffff);
-
- while (*pt != PTABLE_END) {
- if (*pt == key) {
- if (val == 0xffffffff) /* default */
- val = pt[2];
-
- wlc_kmem_write(pt[1], val);
- }
- pt += 3;
- }
-
- return 0;
-}
-
-static int wlc_slottime(wlc_param param, void *data, void *value)
-{
- int *val = (int *) value;
- int ret = 0;
-
- if ((param & PARAM_MODE) == SET) {
- wlc_patcher_setval(PTABLE_SLT1, *val);
- wlc_patcher_setval(PTABLE_SLT2, ((*val == -1) ? *val : *val + 510));
- } else if ((param & PARAM_MODE) == GET) {
- ret = wlc_patcher_getval(PTABLE_SLT1, (unsigned long *) val);
- if (*val != 0xffffffff)
- *val &= 0xffff;
- }
-
- return ret;
-}
-
-static int wlc_noack(wlc_param param, void *data, void *value)
-{
- int *val = (int *) value;
- int ret = 0;
-
- if ((param & PARAM_MODE) == SET) {
- wlc_patcher_setval(PTABLE_ACKW, ((*val) ? 1 : 0));
- } else if ((param & PARAM_MODE) == GET) {
- ret = wlc_patcher_getval(PTABLE_ACKW, (unsigned long *) val);
- *val &= 0xffff;
- *val = (*val ? 1 : 0);
- }
-
- return ret;
-}
-
-static int wlc_ibss_merge(wlc_param param, void *data, void *value)
-{
- int *val = (int *) value;
- int ret = 0;
-
- if ((param & PARAM_MODE) == SET) {
- /* overwrite the instruction with 'lui v0,0x0' - fake a return
- * status of 0 for wlc_bcn_tsf_later */
- wlc_patcher_setval(PTABLE_ACKW, ((*val) ? -1 : 0x3c020000));
- } else if ((param & PARAM_MODE) == GET) {
- ret = wlc_patcher_getval(PTABLE_ACKW, (unsigned long *) val);
- *val = ((*val == -1) ? 1 : 0);
- }
-
- return ret;