clang-format

This commit is contained in:
2024-09-10 13:03:02 -04:00
parent 53c617d779
commit d66450e427
381 changed files with 28864 additions and 34170 deletions

View File

@@ -41,37 +41,29 @@
#include "autoconf.h"
/* Registers (offsets within slot) */
#define LSCR_REG_POSN 0 /* Cursor position */
#define LSCR_REG_SIZE 4 /* Display size */
#define LSCR_REG_CHAR 8 /* Character in */
#define LSCR_REG_RIRQ 12 /* Read interrupt status */
#define LSCR_REG_POSN 0 /* Cursor position */
#define LSCR_REG_SIZE 4 /* Display size */
#define LSCR_REG_CHAR 8 /* Character in */
#define LSCR_REG_RIRQ 12 /* Read interrupt status */
/* Bits in the IRQ registers */
#define LSCR_IRQ_ENABLE 1
#define LSCR_IRQ_ACTIVE 2
#define LSCR_IRQ_ENABLE 1
#define LSCR_IRQ_ACTIVE 2
/* Offset within slot of screen buffer */
#define LSCR_SCREEN 32768
#define LSCR_SCREEN 32768
/* Convert a 32-bit X/Y pair to X and Y coordinates. */
static
inline
void
splitxy(uint32_t xy, unsigned *x, unsigned *y)
{
*x = xy >> 16;
*y = xy & 0xffff;
static inline void splitxy(uint32_t xy, unsigned *x, unsigned *y) {
*x = xy >> 16;
*y = xy & 0xffff;
}
/* Convert X and Y coordinates to a single 32-bit value. */
static
inline
uint32_t
mergexy(unsigned x, unsigned y)
{
uint32_t val = x;
static inline uint32_t mergexy(unsigned x, unsigned y) {
uint32_t val = x;
return (val << 16) | y;
return (val << 16) | y;
}
////////////////////////////////////////////////////////////
@@ -79,29 +71,25 @@ mergexy(unsigned x, unsigned y)
/*
* Interrupt handler.
*/
void
lscreen_irq(void *vsc)
{
struct lscreen_softc *sc = vsc;
uint32_t ch, x;
void lscreen_irq(void *vsc) {
struct lscreen_softc *sc = vsc;
uint32_t ch, x;
spinlock_acquire(&sc->ls_lock);
spinlock_acquire(&sc->ls_lock);
x = bus_read_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_RIRQ);
if (x & LSCR_IRQ_ACTIVE) {
ch = bus_read_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_CHAR);
bus_write_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_RIRQ, LSCR_IRQ_ENABLE);
x = bus_read_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_RIRQ);
if (x & LSCR_IRQ_ACTIVE) {
ch = bus_read_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_CHAR);
bus_write_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_RIRQ,
LSCR_IRQ_ENABLE);
spinlock_release(&sc->ls_lock);
if (sc->ls_input) {
sc->ls_input(sc->ls_devdata, ch);
}
}
else {
spinlock_release(&sc->ls_lock);
}
spinlock_release(&sc->ls_lock);
if (sc->ls_input) {
sc->ls_input(sc->ls_devdata, ch);
}
} else {
spinlock_release(&sc->ls_lock);
}
}
////////////////////////////////////////////////////////////
@@ -109,74 +97,68 @@ lscreen_irq(void *vsc)
/*
* Handle a newline on the screen.
*/
static
void
lscreen_newline(struct lscreen_softc *sc)
{
if (sc->ls_cy >= sc->ls_height-1) {
/*
* Scroll
*/
static void lscreen_newline(struct lscreen_softc *sc) {
if (sc->ls_cy >= sc->ls_height - 1) {
/*
* Scroll
*/
memmove(sc->ls_screen, sc->ls_screen + sc->ls_width,
sc->ls_width * (sc->ls_height-1));
bzero(sc->ls_screen + sc->ls_width * (sc->ls_height-1),
sc->ls_width);
}
else {
sc->ls_cy++;
}
sc->ls_cx=0;
memmove(sc->ls_screen, sc->ls_screen + sc->ls_width,
sc->ls_width * (sc->ls_height - 1));
bzero(sc->ls_screen + sc->ls_width * (sc->ls_height - 1), sc->ls_width);
} else {
sc->ls_cy++;
}
sc->ls_cx = 0;
}
/*
* Handle a printable character being written to the screen.
*/
static
void
lscreen_char(struct lscreen_softc *sc, int ch)
{
if (sc->ls_cx >= sc->ls_width) {
lscreen_newline(sc);
}
static void lscreen_char(struct lscreen_softc *sc, int ch) {
if (sc->ls_cx >= sc->ls_width) {
lscreen_newline(sc);
}
sc->ls_screen[sc->ls_cy*sc->ls_width + sc->ls_cx] = ch;
sc->ls_cx++;
sc->ls_screen[sc->ls_cy * sc->ls_width + sc->ls_cx] = ch;
sc->ls_cx++;
}
/*
* Send a character to the screen.
* This should probably know about backspace and tab.
*/
void
lscreen_write(void *vsc, int ch)
{
struct lscreen_softc *sc = vsc;
int ccx, ccy;
void lscreen_write(void *vsc, int ch) {
struct lscreen_softc *sc = vsc;
int ccx, ccy;
spinlock_acquire(&sc->ls_lock);
spinlock_acquire(&sc->ls_lock);
switch (ch) {
case '\n': lscreen_newline(sc); break;
default: lscreen_char(sc, ch); break;
}
switch (ch) {
case '\n':
lscreen_newline(sc);
break;
default:
lscreen_char(sc, ch);
break;
}
/*
* ccx/ccy = corrected cursor position
* (The cursor marks the next space text will appear in. But
* at the very end of the line, it should not move off the edge.)
*/
ccx = sc->ls_cx;
ccy = sc->ls_cy;
if (ccx==sc->ls_width) {
ccx--;
}
/*
* ccx/ccy = corrected cursor position
* (The cursor marks the next space text will appear in. But
* at the very end of the line, it should not move off the edge.)
*/
ccx = sc->ls_cx;
ccy = sc->ls_cy;
if (ccx == sc->ls_width) {
ccx--;
}
/* Set the cursor position */
bus_write_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_POSN, mergexy(ccx, ccy));
/* Set the cursor position */
bus_write_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_POSN,
mergexy(ccx, ccy));
spinlock_release(&sc->ls_lock);
spinlock_release(&sc->ls_lock);
}
////////////////////////////////////////////////////////////
@@ -184,42 +166,36 @@ lscreen_write(void *vsc, int ch)
/*
* Setup routine called by autoconf.c when an lscreen is found.
*/
int
config_lscreen(struct lscreen_softc *sc, int lscreenno)
{
uint32_t val;
int config_lscreen(struct lscreen_softc *sc, int lscreenno) {
uint32_t val;
(void)lscreenno;
(void)lscreenno;
spinlock_init(&sc->ls_lock);
spinlock_init(&sc->ls_lock);
/*
* Enable interrupting.
*/
/*
* Enable interrupting.
*/
bus_write_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_RIRQ, LSCR_IRQ_ENABLE);
bus_write_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_RIRQ,
LSCR_IRQ_ENABLE);
/*
* Get screen size.
*/
val = bus_read_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_SIZE);
splitxy(val, &sc->ls_width, &sc->ls_height);
/*
* Get screen size.
*/
val = bus_read_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_SIZE);
splitxy(val, &sc->ls_width, &sc->ls_height);
/*
* Get cursor position.
*/
val = bus_read_register(sc->ls_busdata, sc->ls_buspos,
LSCR_REG_POSN);
splitxy(val, &sc->ls_cx, &sc->ls_cy);
/*
* Get cursor position.
*/
val = bus_read_register(sc->ls_busdata, sc->ls_buspos, LSCR_REG_POSN);
splitxy(val, &sc->ls_cx, &sc->ls_cy);
/*
* Get a pointer to the memory-mapped screen area.
*/
sc->ls_screen = bus_map_area(sc->ls_busdata, sc->ls_buspos,
LSCR_SCREEN);
/*
* Get a pointer to the memory-mapped screen area.
*/
sc->ls_screen = bus_map_area(sc->ls_busdata, sc->ls_buspos, LSCR_SCREEN);
return 0;
return 0;
}