}
}
-#define SISUSB_VADDR(x,y) \
- ((u16 *)c->vc_origin + \
- (y) * sisusb->sisusb_num_columns + \
- (x))
+static inline void *sisusb_vaddr(const struct sisusb_usb_data *sisusb,
+ const struct vc_data *c, unsigned int x, unsigned int y)
+{
+ return (u16 *)c->vc_origin + y * sisusb->sisusb_num_columns + x;
+}
+
+static inline unsigned long sisusb_haddr(const struct sisusb_usb_data *sisusb,
+ const struct vc_data *c, unsigned int x, unsigned int y)
+{
+ unsigned long offset = c->vc_origin - sisusb->scrbuf;
+
+ /* 2 bytes per each character */
+ offset += 2 * (y * sisusb->sisusb_num_columns + x);
-#define SISUSB_HADDR(x,y) \
- ((u16 *)(sisusb->vrambase + (c->vc_origin - sisusb->scrbuf)) + \
- (y) * sisusb->sisusb_num_columns + \
- (x))
+ return sisusb->vrambase + offset;
+}
/* Interface routine */
static void
return;
}
-
- sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
- (long)SISUSB_HADDR(x, y), 2);
+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
+ sisusb_haddr(sisusb, c, x, y), 2);
mutex_unlock(&sisusb->lock);
}
* because the vt does this AFTER calling us.
*/
- dest = SISUSB_VADDR(x, y);
+ dest = sisusb_vaddr(sisusb, c, x, y);
for (i = count; i > 0; i--)
sisusbcon_writew(sisusbcon_readw(s++), dest++);
return;
}
- sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
- (long)SISUSB_HADDR(x, y), count * 2);
+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
+ sisusb_haddr(sisusb, c, x, y), count * 2);
mutex_unlock(&sisusb->lock);
}
* this AFTER calling us.
*/
- dest = SISUSB_VADDR(x, y);
+ dest = sisusb_vaddr(sisusb, c, x, y);
cols = sisusb->sisusb_num_columns;
length = ((height * cols) - x - (cols - width - x)) * 2;
- sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y),
- (long)SISUSB_HADDR(x, y), length);
+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, x, y),
+ sisusb_haddr(sisusb, c, x, y), length);
mutex_unlock(&sisusb->lock);
}
sisusbcon_memcpyw((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf,
length);
- sisusb_copy_memory(sisusb, (unsigned char *)c->vc_origin,
- (long)SISUSB_HADDR(0, 0),
- length);
+ sisusb_copy_memory(sisusb, (char *)c->vc_origin,
+ sisusb_haddr(sisusb, c, 0, 0), length);
mutex_unlock(&sisusb->lock);
sisusbcon_memsetw((u16 *)c->vc_origin,
c->vc_video_erase_char,
c->vc_screenbuf_size);
- sisusb_copy_memory(sisusb,
- (unsigned char *)c->vc_origin,
- (u32)(sisusb->vrambase +
- (c->vc_origin - sisusb->scrbuf)),
+ sisusb_copy_memory(sisusb, (char *)c->vc_origin,
+ sisusb_haddr(sisusb, c, 0, 0),
c->vc_screenbuf_size);
sisusb->con_blanked = 1;
ret = 1;
switch (dir) {
case SM_UP:
- sisusbcon_memmovew(SISUSB_VADDR(0, t),
- SISUSB_VADDR(0, t + lines),
+ sisusbcon_memmovew(sisusb_vaddr(sisusb, c, 0, t),
+ sisusb_vaddr(sisusb, c, 0, t + lines),
(b - t - lines) * cols * 2);
- sisusbcon_memsetw(SISUSB_VADDR(0, b - lines), eattr,
- lines * cols * 2);
+ sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, b - lines),
+ eattr, lines * cols * 2);
break;
case SM_DOWN:
- sisusbcon_memmovew(SISUSB_VADDR(0, t + lines),
- SISUSB_VADDR(0, t),
+ sisusbcon_memmovew(sisusb_vaddr(sisusb, c, 0, t + lines),
+ sisusb_vaddr(sisusb, c, 0, t),
(b - t - lines) * cols * 2);
- sisusbcon_memsetw(SISUSB_VADDR(0, t), eattr,
+ sisusbcon_memsetw(sisusb_vaddr(sisusb, c, 0, t), eattr,
lines * cols * 2);
break;
}
- sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t),
- (long)SISUSB_HADDR(0, t), length);
+ sisusb_copy_memory(sisusb, sisusb_vaddr(sisusb, c, 0, t),
+ sisusb_haddr(sisusb, c, 0, t), length);
mutex_unlock(&sisusb->lock);
int copyall = 0;
unsigned long oldorigin;
unsigned int delta = lines * c->vc_size_row;
- u32 originoffset;
/* Returning != 0 means we have done the scrolling successfully.
* Returning 0 makes vt do the scrolling on its own.
break;
}
- originoffset = (u32)(c->vc_origin - sisusb->scrbuf);
-
if (copyall)
sisusb_copy_memory(sisusb,
(char *)c->vc_origin,
- (u32)(sisusb->vrambase + originoffset),
+ sisusb_haddr(sisusb, c, 0, 0),
c->vc_screenbuf_size);
else if (dir == SM_UP)
sisusb_copy_memory(sisusb,
(char *)c->vc_origin + c->vc_screenbuf_size - delta,
- (u32)sisusb->vrambase + originoffset +
+ sisusb_haddr(sisusb, c, 0, 0) +
c->vc_screenbuf_size - delta,
delta);
else
sisusb_copy_memory(sisusb,
(char *)c->vc_origin,
- (u32)(sisusb->vrambase + originoffset),
+ sisusb_haddr(sisusb, c, 0, 0),
delta);
c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;