Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/luna68k/stand/boot Misc cleanup. Mostly from OpenB...
details: https://anonhg.NetBSD.org/src/rev/f9824e478dee
branches: trunk
changeset: 325661:f9824e478dee
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Jan 02 20:02:00 2014 +0000
description:
Misc cleanup. Mostly from OpenBSD/luna88k.
- fix isprint() macro
- hight -> height
- remove an unused function
- adjust tabs/spaces
- constify the bitmap font
- consistently use #define<space>
- use #if 0/#endif to disable code block
- u_long -> uint32_t, u_short -> uint16_t
- some KNF
diffstat:
sys/arch/luna68k/stand/boot/bmd.c | 180 ++++++++++++++++---------------
sys/arch/luna68k/stand/boot/font.c | 4 +-
sys/arch/luna68k/stand/boot/samachdep.h | 4 +-
3 files changed, 95 insertions(+), 93 deletions(-)
diffs (truncated from 415 to 300 lines):
diff -r 6c12e48025d6 -r f9824e478dee sys/arch/luna68k/stand/boot/bmd.c
--- a/sys/arch/luna68k/stand/boot/bmd.c Thu Jan 02 19:50:03 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/bmd.c Thu Jan 02 20:02:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bmd.c,v 1.2 2013/01/20 13:35:43 tsutsui Exp $ */
+/* $NetBSD: bmd.c,v 1.3 2014/01/02 20:02:00 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -80,8 +80,6 @@
#include <sys/param.h>
#include <luna68k/stand/boot/samachdep.h>
-#define isprint(c) ( c < 0x20 ? 0 : 1)
-
/*
* RFCNT register
*/
@@ -94,37 +92,36 @@
uint32_t u;
};
+#define isprint(c) ((c) >= 0x20 && (c) < 0x7f)
/*
- * Width & Hight
+ * Width & Height
*/
-#define PB_WIDTH 2048 /* Plane Width (Bit) */
-#define PB_HIGHT 1024 /* Plane Hight (Bit) */
-#define PL_WIDTH 64 /* Plane Width (long) */
-#define PS_WIDTH 128 /* Plane Width (long) */
-#define P_WIDTH 256 /* Plane Width (Byte) */
+#define PB_WIDTH 2048 /* Plane Width (Bit) */
+#define PB_HEIGHT 1024 /* Plane Hight (Bit) */
+#define PL_WIDTH 64 /* Plane Width (long) */
+#define PS_WIDTH 128 /* Plane Width (long) */
+#define P_WIDTH 256 /* Plane Width (Byte) */
-#define SB_WIDTH 1280 /* Screen Width (Bit) */
-#define SB_HIGHT 1024 /* Screen Hight (Bit) */
-#define SL_WIDTH 40 /* Screen Width (Long) */
-#define S_WIDTH 160 /* Screen Width (Byte) */
+#define SB_WIDTH 1280 /* Screen Width (Bit) */
+#define SB_HEIGHT 1024 /* Screen Hight (Bit) */
+#define SL_WIDTH 40 /* Screen Width (Long) */
+#define S_WIDTH 160 /* Screen Width (Byte) */
-#define FB_WIDTH 12 /* Font Width (Bit) */
-#define FB_HIGHT 20 /* Font Hight (Bit) */
+#define FB_WIDTH 12 /* Font Width (Bit) */
+#define FB_HEIGHT 20 /* Font Hight (Bit) */
-#define NEXT_LINE(addr) ( addr + (PL_WIDTH * FB_HIGHT) )
-#define SKIP_NEXT_LINE(addr) ( addr += (PL_WIDTH - SL_WIDTH) )
+#define NEXT_LINE(addr) ( addr + (PL_WIDTH * FB_HEIGHT) )
+#define SKIP_NEXT_LINE(addr) ( addr += (PL_WIDTH - SL_WIDTH) )
-void bmd_add_new_line(void);
-
void bmd_draw_char(char *, char *, int, int, int);
void bmd_reverse_char(char *, char *, int, int);
void bmd_erase_char(char *, char *, int, int);
-void bmd_erase_screen(volatile u_long *);
-void bmd_scroll_screen(volatile u_long *, volatile u_long *,
+void bmd_erase_screen(volatile uint32_t *);
+void bmd_scroll_screen(volatile uint32_t *, volatile uint32_t *,
int, int, int, int);
@@ -152,9 +149,9 @@
void (*bc_escape)(int);
};
-#define STAT_NORMAL 0x0000
-#define STAT_ESCAPE 0x0001
-#define STAT_INSERT 0x0100
+#define STAT_NORMAL 0x0000
+#define STAT_ESCAPE 0x0001
+#define STAT_INSERT 0x0100
struct bmd_softc bmd_softc;
struct bmd_linec bmd_linec[52];
@@ -224,11 +221,11 @@
break;
default:
-/*
+#if 0
*bp->bc_esc++ = c;
bp->bc_escape = bmd_escape_1;
return;
- */
+#endif
break;
}
@@ -293,10 +290,10 @@
* adjust plane position
*/
- bp->bc_raddr = (char *) 0xB10C0008; /* plane-0 hardware address */
- bp->bc_waddr = (char *) 0xB1080008; /* common bitmap hardware address */
- rfcnt.p.rfc_hcnt = 7; /* shift left 16 dot */
- rfcnt.p.rfc_vcnt = -27; /* shift down 1 dot */
+ bp->bc_raddr = (char *) 0xB10C0008; /* plane-0 hardware address */
+ bp->bc_waddr = (char *) 0xB1080008; /* common bitmap hardware address */
+ rfcnt.p.rfc_hcnt = 7; /* shift left 16 dot */
+ rfcnt.p.rfc_vcnt = -27; /* shift down 1 dot */
*bmd_rfcnt = rfcnt.u;
bp->bc_stat = STAT_NORMAL;
@@ -324,7 +321,7 @@
bp->bc_escape = bmd_escape;
*bmd_bmsel = 0xff; /* all planes */
- bmd_erase_screen((u_long *) bp->bc_waddr); /* clear screen */
+ bmd_erase_screen((uint32_t *)bp->bc_waddr); /* clear screen */
*bmd_bmsel = 0x01; /* 1 plane */
/* turn on cursole */
@@ -375,8 +372,8 @@
bq->bl_col = bq->bl_end = bp->bc_xmin;
bp->bc_row++;
if (bp->bc_row >= bp->bc_ymax) {
- bmd_scroll_screen((u_long *) bp->bc_raddr,
- (u_long *) bp->bc_waddr,
+ bmd_scroll_screen((uint32_t *)bp->bc_raddr,
+ (uint32_t *)bp->bc_waddr,
bp->bc_xmin, bp->bc_xmax,
bp->bc_ymin, bp->bc_ymax);
@@ -402,8 +399,8 @@
case 0x0A: /* NL */
bp->bc_row++;
if (bp->bc_row >= bp->bc_ymax) {
- bmd_scroll_screen((u_long *) bp->bc_raddr,
- (u_long *) bp->bc_waddr,
+ bmd_scroll_screen((uint32_t *)bp->bc_raddr,
+ (uint32_t *)bp->bc_waddr,
bp->bc_xmin, bp->bc_xmax,
bp->bc_ymin, bp->bc_ymax);
@@ -449,7 +446,7 @@
struct bmd_softc *bp = &bmd_softc;
struct bmd_linec *bq = bp->bc_bl;
- bmd_erase_screen((u_long *) bp->bc_waddr); /* clear screen */
+ bmd_erase_screen((uint32_t *)bp->bc_waddr); /* clear screen */
bq->bl_col = bq->bl_end = bp->bc_xmin;
bp->bc_row = bp->bc_ymin;
@@ -461,24 +458,15 @@
/*
- *
- */
-
-void
-bmd_add_new_line(void)
-{
-}
-
-
-/*
* charactor operation routines
*/
void
bmd_draw_char(char *raddr, char *waddr, int col, int row, int c)
{
- volatile u_short *p, *q, *fp;
- volatile u_long *lp, *lq;
+ volatile uint16_t *p, *q;
+ volatile uint32_t *lp, *lq;
+ const uint16_t *fp;
int i;
fp = &bmdfont[c][0];
@@ -486,9 +474,11 @@
switch (col % 4) {
case 0:
- p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- for (i = 0; i < FB_HIGHT; i++) {
+ p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ for (i = 0; i < FB_HEIGHT; i++) {
*q = (*p & 0x000F) | (*fp & 0xFFF0);
p += 128;
q += 128;
@@ -497,10 +487,13 @@
break;
case 1:
- lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- for (i = 0; i < FB_HIGHT; i++) {
- *lq = (*lp & 0xFFF000FF) | ((u_long)(*fp & 0xFFF0) << 4);
+ lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ for (i = 0; i < FB_HEIGHT; i++) {
+ *lq = (*lp & 0xFFF000FF) |
+ ((uint32_t)(*fp & 0xFFF0) << 4);
lp += 64;
lq += 64;
fp++;
@@ -508,10 +501,13 @@
break;
case 2:
- lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
- lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
- for (i = 0; i < FB_HIGHT; i++) {
- *lq = (*lp & 0xFF000FFF) | ((u_long)(*fp & 0xFFF0) << 8);
+ lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 2);
+ lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 2);
+ for (i = 0; i < FB_HEIGHT; i++) {
+ *lq = (*lp & 0xFF000FFF) |
+ ((uint32_t)(*fp & 0xFFF0) << 8);
lp += 64;
lq += 64;
fp++;
@@ -519,9 +515,11 @@
break;
case 3:
- p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
- q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
- for (i = 0; i < FB_HIGHT; i++) {
+ p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 4);
+ q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 4);
+ for (i = 0; i < FB_HEIGHT; i++) {
*q = (*p & 0xF000) | ((*fp & 0xFFF0) >> 4);
p += 128;
q += 128;
@@ -537,16 +535,18 @@
void
bmd_reverse_char(char *raddr, char *waddr, int col, int row)
{
- volatile u_short *p, *q;
- volatile u_long *lp, *lq;
+ volatile uint16_t *p, *q;
+ volatile uint32_t *lp, *lq;
int i;
- switch (col%4) {
+ switch (col % 4) {
case 0:
- p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- for (i = 0; i < FB_HIGHT; i++) {
+ p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ for (i = 0; i < FB_HEIGHT; i++) {
*q = (*p & 0x000F) | (~(*p) & 0xFFF0);
p += 128;
q += 128;
@@ -554,9 +554,11 @@
break;
case 1:
- lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
- for (i = 0; i < FB_HIGHT; i++) {
+ lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6));
+ for (i = 0; i < FB_HEIGHT; i++) {
*lq = (*lp & 0xFFF000FF) | (~(*lp) & 0x000FFF00);
lp += 64;
lq += 64;
@@ -564,9 +566,11 @@
break;
case 2:
- lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
- lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
- for (i = 0; i < FB_HIGHT; i++) {
+ lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 2);
+ lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
+ + ((col / 4) * 6) + 2);
Home |
Main Index |
Thread Index |
Old Index