Skip to content

Commit f853798

Browse files
authored
Enforce column limit of 100 (#4)
* Make column limit 100 * Apply formatting
1 parent 6529b20 commit f853798

12 files changed

Lines changed: 884 additions & 194 deletions

File tree

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ TabWidth: 4
33
IndentWidth: 4
44
PointerAlignment: Left
55
SpaceBeforeParens: Always
6-
ColumnLimit: 150
6+
ColumnLimit: 100
77
BreakBeforeBraces: Attach

src/kernel/console.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
bool PUTCH_UPDATE = false;
1414

15-
unsigned char bufferstr[CONSOLE_HEIGHT * CONSOLE_WIDTH] = {0}; // TODO: replace this with malloc when implemented
16-
uint32_t colorbufferstr[CONSOLE_HEIGHT * CONSOLE_WIDTH] = {0xffffff}; // TODO: replace this with malloc when implemented
15+
unsigned char bufferstr[CONSOLE_HEIGHT * CONSOLE_WIDTH] = {
16+
0}; // TODO: replace this with malloc when implemented
17+
uint32_t colorbufferstr[CONSOLE_HEIGHT * CONSOLE_WIDTH] = {
18+
0xffffff}; // TODO: replace this with malloc when implemented
1719
unsigned char* buffer = bufferstr;
1820
uint32_t* colorbuffer = colorbufferstr;
1921
size_t x, y, xs, ys, xsp, ysp, xc, yc, fs;
@@ -60,12 +62,15 @@ Initialise the console with the default (classic) font
6062
@param y_spc spacing between lines
6163
@param font_size font size
6264
*/
63-
void __init_console__ (size_t x_screen, size_t y_screen, size_t x_pad, size_t y_pad, size_t x_spc, size_t y_spc, size_t font_size) {
65+
void __init_console__ (size_t x_screen, size_t y_screen, size_t x_pad, size_t y_pad, size_t x_spc,
66+
size_t y_spc, size_t font_size) {
6467
x = x_screen - 2 * x_pad;
6568
y = y_screen - 2 * y_pad;
6669

67-
xc = (x / ((5 + x_spc) * font_size) > CONSOLE_WIDTH) ? CONSOLE_WIDTH : x / ((5 + x_spc) * font_size);
68-
yc = (y / ((8 + y_spc) * font_size) > CONSOLE_HEIGHT) ? CONSOLE_HEIGHT : y / ((8 + y_spc) * font_size);
70+
xc = (x / ((5 + x_spc) * font_size) > CONSOLE_WIDTH) ? CONSOLE_WIDTH
71+
: x / ((5 + x_spc) * font_size);
72+
yc = (y / ((8 + y_spc) * font_size) > CONSOLE_HEIGHT) ? CONSOLE_HEIGHT
73+
: y / ((8 + y_spc) * font_size);
6974

7075
xsp = x_spc;
7176
ysp = y_spc;
@@ -92,7 +97,8 @@ Update the display.
9297
void update () {
9398
for (size_t i = 0; i < yc; i++) {
9499
for (size_t j = 0; j < xc; j++) {
95-
renderGlyph (glyph (buffer[i * xc + j]), 8, 5, xs + (fs * j * (5 + xsp)), ys + (fs * i * (8 + ysp)), fs, colorbuffer[i * xc + j]);
100+
renderGlyph (glyph (buffer[i * xc + j]), 8, 5, xs + (fs * j * (5 + xsp)),
101+
ys + (fs * i * (8 + ysp)), fs, colorbuffer[i * xc + j]);
96102
}
97103
}
98104
}

src/kernel/entry.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Entry point of kernel. Everything is set up here.
3636
*/
3737
void _start (void) {
3838
// Ensure we got a framebuffer.
39-
if (framebuffer_request.response == NULL || framebuffer_request.response->framebuffer_count < 1) {
39+
if (framebuffer_request.response == NULL ||
40+
framebuffer_request.response->framebuffer_count < 1) {
4041
hcf ();
4142
}
4243

src/kernel/graphics.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ Place a character on the screen
5858
@param size_mult size of character as a multipler (1 for default size)
5959
@param color color of character
6060
*/
61-
void renderGlyph (unsigned char* glyph, int gh, int gw, size_t posx, size_t posy, int size_mult, uint32_t color) {
61+
void renderGlyph (unsigned char* glyph, int gh, int gw, size_t posx, size_t posy, int size_mult,
62+
uint32_t color) {
6263
for (int i = 0; i < gh; i++)
6364
for (int j = 0; j < gw; j++)
6465
for (int kx = 0; kx < size_mult; kx++)
6566
for (int ky = 0; ky < size_mult; ky++)
66-
putPixel (glyph[i * gw + j] ? color : 0, posx + (j * size_mult) + kx, posy + (i * size_mult) + ky);
67+
putPixel (glyph[i * gw + j] ? color : 0, posx + (j * size_mult) + kx,
68+
posy + (i * size_mult) + ky);
6769
}
6870

6971
/*!

src/kernel/hardfonts/classic.c

Lines changed: 772 additions & 129 deletions
Large diffs are not rendered by default.

src/kernel/hw/pic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ inline void pic_send_eoi (uint8_t irq) {
3131
* @param offset2 slave PIC vector offset
3232
*/
3333
static void pic_remap (int offset1, int offset2) {
34-
outb (PIC1_COMMAND, ICW1_INIT | ICW1_ICW4); // starts the initialization sequence (in cascade mode)
34+
outb (PIC1_COMMAND,
35+
ICW1_INIT | ICW1_ICW4); // starts the initialization sequence (in cascade mode)
3536
io_wait ();
3637
outb (PIC2_COMMAND, ICW1_INIT | ICW1_ICW4);
3738
io_wait ();

src/kernel/idt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ void kernel_dispatch_interrupt (registers_t* registers) {
8787
}
8888
}
8989

90-
void idt_register_handler (int vector, irq_handler_t handler) { interrupt_handlers[vector] = handler; }
90+
void idt_register_handler (int vector, irq_handler_t handler) {
91+
interrupt_handlers[vector] = handler;
92+
}
9193

9294
void __init_idt__ (void) {
9395
idtr.size = (uint16_t)(sizeof (idt_entry_t) * 256) - 1;

src/kernel/io.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* @param port port to write
77
* @param val value to write
88
*/
9-
inline void outb (uint16_t port, uint8_t val) { __asm__ volatile ("outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory"); }
9+
inline void outb (uint16_t port, uint8_t val) {
10+
__asm__ volatile ("outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory");
11+
}
1012

1113
/*!
1214
* Read a single byte from a port

src/kernel/limine_requests.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
__attribute__ ((used, section (".limine_requests"))) static volatile LIMINE_BASE_REVISION (3);
44

5-
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_framebuffer_request framebuffer_request = {
6-
.id = LIMINE_FRAMEBUFFER_REQUEST, .revision = 0};
5+
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_framebuffer_request
6+
framebuffer_request = {.id = LIMINE_FRAMEBUFFER_REQUEST, .revision = 0};
77

8-
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_bootloader_info_request bootinfo_req = {
9-
.id = LIMINE_BOOTLOADER_INFO_REQUEST, .revision = 0};
8+
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_bootloader_info_request
9+
bootinfo_req = {.id = LIMINE_BOOTLOADER_INFO_REQUEST, .revision = 0};
1010

11-
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_boot_time_request boottime_req = {.id = LIMINE_BOOT_TIME_REQUEST,
12-
.revision = 0};
11+
__attribute__ ((
12+
used, section (".limine_requests"))) volatile struct limine_boot_time_request boottime_req = {
13+
.id = LIMINE_BOOT_TIME_REQUEST, .revision = 0};
1314

14-
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_memmap_request memmap_req = {.id = LIMINE_MEMMAP_REQUEST, .revision = 0};
15+
__attribute__ ((used,
16+
section (".limine_requests"))) volatile struct limine_memmap_request memmap_req = {
17+
.id = LIMINE_MEMMAP_REQUEST, .revision = 0};
1518

16-
__attribute__ ((used, section (".limine_requests"))) volatile struct limine_hhdm_request hhdm_req = {.id = LIMINE_HHDM_REQUEST, .revision = 0};
19+
__attribute__ ((used,
20+
section (".limine_requests"))) volatile struct limine_hhdm_request hhdm_req = {
21+
.id = LIMINE_HHDM_REQUEST, .revision = 0};
1722

18-
__attribute__ ((used, section (".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER;
23+
__attribute__ ((used,
24+
section (".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER;
1925

2026
__attribute__ ((used, section (".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER;

src/kernel/memmgt.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,24 @@ void init_memmgt (uint64_t p_hhdm_offset, struct limine_memmap_response* memmap_
9797
for (int i = 0; i < 1; i++) {
9898
memmap.pdpt_entry[i].present = 1;
9999
memmap.pdpt_entry[i].read_write = 1;
100-
memmap.pdpt_entry[i].pd_base_address = ((uint64_t)(get_paddr (&memmap.pd_entry[i * 512])) >> 12) & 0xFFFFFFFFFF;
100+
memmap.pdpt_entry[i].pd_base_address =
101+
((uint64_t)(get_paddr (&memmap.pd_entry[i * 512])) >> 12) & 0xFFFFFFFFFF;
101102
memmap.pdpt_entry[i].xd = 1;
102103
}
103104

104105
for (int i = 0; i < 1; i++) {
105106
memmap.pd_entry[i].present = 1;
106107
memmap.pd_entry[i].rw = 1;
107108
memmap.pd_entry[i].nex = 1;
108-
memmap.pd_entry[i].pt_base_address = ((uint64_t)(get_paddr (&memmap.pt_entry[i * 512])) >> 12) & 0xFFFFFFFFFF;
109+
memmap.pd_entry[i].pt_base_address =
110+
((uint64_t)(get_paddr (&memmap.pt_entry[i * 512])) >> 12) & 0xFFFFFFFFFF;
109111
}
110112

111113
for (int i = 0; i < 512; i++) {
112114
memmap.pt_entry[i].present = 1;
113115
memmap.pt_entry[i].rw = 1;
114-
memmap.pt_entry[i].frame_base_address = ((uint64_t)(alloc_frames_base + PAGE_SIZE * i) >> 12) & 0xFFFFFFFFFF;
116+
memmap.pt_entry[i].frame_base_address =
117+
((uint64_t)(alloc_frames_base + PAGE_SIZE * i) >> 12) & 0xFFFFFFFFFF;
115118
}
116119

117120
// initialise PML4T idx 1 and PDPT idx 0 for our page assignments
@@ -152,7 +155,8 @@ void walk_pagetable () {
152155
if (!pml4t_entry->present)
153156
return;
154157

155-
pdpt_entry_t* pdpt_base_ptr = (pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset);
158+
pdpt_entry_t* pdpt_base_ptr =
159+
(pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset);
156160
pdpt_entry_t* pdpt_entry = &pdpt_base_ptr[0];
157161
if (!pdpt_entry->present)
158162
return;
@@ -207,7 +211,8 @@ void* get_paddr (void* vaddr) {
207211
if (!pml4t_entry->present)
208212
return NULL;
209213

210-
pdpt_entry_t* pdpt_base_ptr = (pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset);
214+
pdpt_entry_t* pdpt_base_ptr =
215+
(pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset);
211216
pdpt_entry_t* pdpt_entry = &pdpt_base_ptr[pdpt_index];
212217
if (!pdpt_entry->present)
213218
return NULL;
@@ -270,7 +275,8 @@ void* liballoc_alloc (size_t count) {
270275
pml4t_entry_t* pml4t_entry = &pml4_base_ptr[1];
271276
if (!pml4t_entry->present)
272277
return NULL;
273-
pdpt_entry_t* pdpt_entry = &((pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset))[0];
278+
pdpt_entry_t* pdpt_entry =
279+
&((pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset))[0];
274280
if (!pdpt_entry->present)
275281
return NULL;
276282
pd_entry_t* pd_entry = &((pd_entry_t*)((pdpt_entry->pd_base_address << 12) + hhdm_offset))[0];
@@ -292,10 +298,12 @@ int liballoc_free (void* ptr, size_t count) {
292298
pml4t_entry_t* pml4t_entry = &pml4_base_ptr[(virtual_addr >> 39) & 0x1FF];
293299
if (!pml4t_entry->present || ((virtual_addr >> 39) & 0x1FF) != 1)
294300
return -2;
295-
pdpt_entry_t* pdpt_entry = &((pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) + hhdm_offset))[(virtual_addr >> 30) & 0x1FF];
301+
pdpt_entry_t* pdpt_entry = &((pdpt_entry_t*)((pml4t_entry->pdpt_base_address << 12) +
302+
hhdm_offset))[(virtual_addr >> 30) & 0x1FF];
296303
if (!pdpt_entry->present || ((virtual_addr >> 30) & 0x1FF) != 0)
297304
return -3;
298-
pd_entry_t* pd_entry = &((pd_entry_t*)((pdpt_entry->pd_base_address << 12) + hhdm_offset))[(virtual_addr >> 21) & 0x1FF];
305+
pd_entry_t* pd_entry = &((pd_entry_t*)((pdpt_entry->pd_base_address << 12) +
306+
hhdm_offset))[(virtual_addr >> 21) & 0x1FF];
299307
if (!pd_entry->present || ((virtual_addr >> 21) & 0x1FF) != 0)
300308
return -4;
301309
pt_entry_t* pt_base_ptr = (pt_entry_t*)((pd_entry->pt_base_address << 12) + hhdm_offset);

0 commit comments

Comments
 (0)