fix for fragment keys
This commit is contained in:
parent
d2ed8e8361
commit
9e8e50ed4a
12
ahci.c
12
ahci.c
@ -87,7 +87,7 @@ int ahci_write_sectors(struct ahci_device_t *dev, int pt, uint32_t startl, uint3
|
||||
memcpy((char *)dev->devices[pt]->prdt_base, (char *)buf, 512);
|
||||
|
||||
port->is = (uint32_t)-1; // Clear pending interrupt bits
|
||||
int spin = 0; // Spin lock timeout counter
|
||||
int spin = 0; // Spin lock timeout counter
|
||||
int slot = ahci_find_cmdslot(dev, pt);
|
||||
if (slot == -1) {
|
||||
return 0;
|
||||
@ -95,8 +95,8 @@ int ahci_write_sectors(struct ahci_device_t *dev, int pt, uint32_t startl, uint3
|
||||
HBA_CMD_HEADER *cmdheader = (HBA_CMD_HEADER *)(dev->devices[pt]->base + (port->clb - dev->devices[pt]->base_phys));
|
||||
cmdheader += slot;
|
||||
cmdheader->cfl = sizeof(FIS_REG_H2D) / sizeof(uint32_t); // Command FIS size
|
||||
cmdheader->w = 1; // Read from device
|
||||
cmdheader->prdtl = 1; // PRDT entries count
|
||||
cmdheader->w = 1; // Read from device
|
||||
cmdheader->prdtl = 1; // PRDT entries count
|
||||
|
||||
HBA_CMD_TBL *cmdtbl = (HBA_CMD_TBL *)(dev->devices[pt]->base + (cmdheader[dev->devices[pt]->port].ctba - dev->devices[pt]->base_phys));
|
||||
memset(cmdtbl, 0, sizeof(HBA_CMD_TBL) + (cmdheader->prdtl - 1) * sizeof(HBA_PRDT_ENTRY));
|
||||
@ -161,7 +161,7 @@ int ahci_read_sectors(struct ahci_device_t *dev, int pt, uint32_t startl, uint32
|
||||
HBA_PORT *port = &dev->abar->ports[pt];
|
||||
|
||||
port->is = (uint32_t)-1; // Clear pending interrupt bits
|
||||
int spin = 0; // Spin lock timeout counter
|
||||
int spin = 0; // Spin lock timeout counter
|
||||
int slot = ahci_find_cmdslot(dev, pt);
|
||||
if (slot == -1) {
|
||||
return 0;
|
||||
@ -169,8 +169,8 @@ int ahci_read_sectors(struct ahci_device_t *dev, int pt, uint32_t startl, uint32
|
||||
HBA_CMD_HEADER *cmdheader = (HBA_CMD_HEADER *)(dev->devices[pt]->base + (port->clb - dev->devices[pt]->base_phys));
|
||||
cmdheader += slot;
|
||||
cmdheader->cfl = sizeof(FIS_REG_H2D) / sizeof(uint32_t); // Command FIS size
|
||||
cmdheader->w = 0; // Read from device
|
||||
cmdheader->prdtl = 1; // PRDT entries count
|
||||
cmdheader->w = 0; // Read from device
|
||||
cmdheader->prdtl = 1; // PRDT entries count
|
||||
|
||||
HBA_CMD_TBL *cmdtbl = (HBA_CMD_TBL *)(dev->devices[pt]->base + (cmdheader[dev->devices[pt]->port].ctba - dev->devices[pt]->base_phys));
|
||||
memset(cmdtbl, 0, sizeof(HBA_CMD_TBL) + (cmdheader->prdtl - 1) * sizeof(HBA_PRDT_ENTRY));
|
||||
|
24
ahci.h
24
ahci.h
@ -153,18 +153,18 @@ typedef struct tagFIS_DMA_SETUP {
|
||||
// DWORD 0
|
||||
uint8_t fis_type; // FIS_TYPE_DMA_SETUP
|
||||
|
||||
uint8_t pmport : 4; // Port multiplier
|
||||
uint8_t rsv0 : 1; // Reserved
|
||||
uint8_t d : 1; // Data transfer direction, 1 - device to host
|
||||
uint8_t i : 1; // Interrupt bit
|
||||
uint8_t a : 1; // Auto-activate. Specifies if DMA Activate FIS is needed
|
||||
uint8_t rsved[2]; // Reserved
|
||||
uint64_t DMAbufferID; // DMA Buffer Identifier. Used to Identify DMA buffer in host memory. SATA Spec says host specific and not in Spec. Trying
|
||||
// AHCI spec might work.
|
||||
uint32_t rsvd; // More reserved
|
||||
uint32_t DMAbufOffset; // Byte offset into buffer. First 2 bits must be 0
|
||||
uint32_t TransferCount; // Number of bytes to transfer. Bit 0 must be 0
|
||||
uint32_t resvd; // Reserved
|
||||
uint8_t pmport : 4; // Port multiplier
|
||||
uint8_t rsv0 : 1; // Reserved
|
||||
uint8_t d : 1; // Data transfer direction, 1 - device to host
|
||||
uint8_t i : 1; // Interrupt bit
|
||||
uint8_t a : 1; // Auto-activate. Specifies if DMA Activate FIS is needed
|
||||
uint8_t rsved[2]; // Reserved
|
||||
uint64_t DMAbufferID; // DMA Buffer Identifier. Used to Identify DMA buffer in host memory. SATA Spec says host specific and not in Spec. Trying
|
||||
// AHCI spec might work.
|
||||
uint32_t rsvd; // More reserved
|
||||
uint32_t DMAbufOffset; // Byte offset into buffer. First 2 bits must be 0
|
||||
uint32_t TransferCount; // Number of bytes to transfer. Bit 0 must be 0
|
||||
uint32_t resvd; // Reserved
|
||||
} FIS_DMA_SETUP;
|
||||
|
||||
typedef volatile struct tagHBA_MEM {
|
||||
|
3
arp.c
3
arp.c
@ -40,7 +40,8 @@ void arp_process_packet(struct ether_t *ether, struct arp_packet_t *packet) {
|
||||
arp_packet.tha[4] = packet->sha[4];
|
||||
arp_packet.tha[5] = packet->sha[5];
|
||||
arp_packet.tpa = packet->spa;
|
||||
struct ether_packet_t *ether_packet = (struct ether_packet_t *)dbmalloc(sizeof(struct arp_packet_t) + sizeof(struct ether_packet_t), "arp_process_packet 1");
|
||||
struct ether_packet_t *ether_packet =
|
||||
(struct ether_packet_t *)dbmalloc(sizeof(struct arp_packet_t) + sizeof(struct ether_packet_t), "arp_process_packet 1");
|
||||
|
||||
ether_packet->destmac[0] = packet->sha[0];
|
||||
ether_packet->destmac[1] = packet->sha[1];
|
||||
|
@ -62,7 +62,7 @@ void console_display_quinn();
|
||||
|
||||
static uint32_t console_col_map[16] = {0xff000000, 0xff0000AA, 0xff00AA00, 0xff00AAAA, 0xffAA0000, 0xffAA00AA, 0xffAA5500, 0xffAAAAAA,
|
||||
|
||||
0xff555555, 0xff5555FF, 0xff55FF55, 0xff55FFFF, 0xffFF5555, 0xffFF55FF, 0xffFFFF55, 0xffFFFFFF};
|
||||
0xff555555, 0xff5555FF, 0xff55FF55, 0xff55FFFF, 0xffFF5555, 0xffFF55FF, 0xffFFFF55, 0xffFFFFFF};
|
||||
|
||||
extern void mem_reserve(char *blk, int pages);
|
||||
|
||||
|
3
ether.h
3
ether.h
@ -5,8 +5,7 @@
|
||||
|
||||
#define htons(A) ((((uint16_t)(A)&0xff00) >> 8) | (((uint16_t)(A)&0x00ff) << 8))
|
||||
#define htonl(A) \
|
||||
((((uint32_t)(A)&0xff000000) >> 24) | (((uint32_t)(A)&0x00ff0000) >> 8) | (((uint32_t)(A)&0x0000ff00) << 8) | \
|
||||
(((uint32_t)(A)&0x000000ff) << 24))
|
||||
((((uint32_t)(A)&0xff000000) >> 24) | (((uint32_t)(A)&0x00ff0000) >> 8) | (((uint32_t)(A)&0x0000ff00) << 8) | (((uint32_t)(A)&0x000000ff) << 24))
|
||||
|
||||
#define ETH_MIN_PACKET_SIZE 60
|
||||
|
||||
|
13
gui.c
13
gui.c
@ -28,8 +28,8 @@ struct gui_colour_scheme_t sys_color;
|
||||
outportw(0x8A00, 0x08AE0);
|
||||
#define BochsConsolePrintChar(c) outportb(0xe9, c)
|
||||
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width,
|
||||
uint32_t dest_height, uint32_t src_depth);
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width, uint32_t dest_height,
|
||||
uint32_t src_depth);
|
||||
void gui_pagemap();
|
||||
|
||||
struct ModeInfoBlock {
|
||||
@ -359,8 +359,7 @@ int gui_change_window_caption(int serialno, char *cap) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gui_add_window(uint8_t *contents, char *name, int x, int y, int w, int h, uint8_t *icon, uint32_t flags,
|
||||
void (*keyboard_d)(uint8_t c, uint8_t state)) {
|
||||
int gui_add_window(uint8_t *contents, char *name, int x, int y, int w, int h, uint8_t *icon, uint32_t flags, void (*keyboard_d)(uint8_t c, uint8_t state)) {
|
||||
struct window_t *new_window;
|
||||
|
||||
new_window = (struct window_t *)dbmalloc(sizeof(struct window_t), "gui: add window (malloc 1)");
|
||||
@ -879,8 +878,8 @@ static uint32_t blendPreMulAlpha(uint32_t p1, uint32_t p2) {
|
||||
return ((rb & RBMASK) | (ag & AGMASK));
|
||||
}
|
||||
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width,
|
||||
uint32_t dest_height, uint32_t src_depth) {
|
||||
void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height, int dest_x, int dest_y, uint32_t dest_width, uint32_t dest_height,
|
||||
uint32_t src_depth) {
|
||||
int i;
|
||||
int pitch = dest_width * depth;
|
||||
int src_off_x = 0;
|
||||
@ -922,7 +921,7 @@ void render(uint8_t *dest, uint8_t *src, uint32_t src_width, uint32_t src_height
|
||||
if (psrc[index + (src_off_x * src_depth) + 3] < 0xFF) {
|
||||
uint32_t pixel1 = (pdest[dindex + 3] << 24) | (pdest[dindex + 2] << 16) | (pdest[dindex + 1] << 8) | pdest[dindex];
|
||||
uint32_t pixel2 = (psrc[index + (src_off_x * src_depth) + 3] << 24) | (psrc[index + (src_off_x * src_depth) + 2] << 16) |
|
||||
(psrc[index + (src_off_x * src_depth) + 1] << 8) | psrc[index + (src_off_x * src_depth)];
|
||||
(psrc[index + (src_off_x * src_depth) + 1] << 8) | psrc[index + (src_off_x * src_depth)];
|
||||
uint32_t pixel3 = blendPreMulAlpha(pixel1, pixel2);
|
||||
|
||||
pdest[dindex] = pixel3 & 0xff;
|
||||
|
@ -35,7 +35,7 @@ map_t hashmap_new() {
|
||||
|
||||
m->data = (hashmap_element *)dbmalloc(sizeof(hashmap_element) * INITIAL_SIZE, "hashmap new 2");
|
||||
memset(m->data, 0, sizeof(hashmap_element) * INITIAL_SIZE);
|
||||
// m->data = (hashmap_element *)calloc(INITIAL_SIZE, sizeof(hashmap_element));
|
||||
// m->data = (hashmap_element *)calloc(INITIAL_SIZE, sizeof(hashmap_element));
|
||||
if (!m->data)
|
||||
goto err;
|
||||
|
||||
@ -197,7 +197,7 @@ int hashmap_rehash(map_t in) {
|
||||
hashmap_map *m = (hashmap_map *)in;
|
||||
hashmap_element *temp = (hashmap_element *)dbmalloc((2 * m->table_size) * sizeof(hashmap_element), "hashmap rehash");
|
||||
memset(temp, 0, (2 * m->table_size) * sizeof(hashmap_element));
|
||||
//hashmap_element *temp = (hashmap_element *)calloc(2 * m->table_size, sizeof(hashmap_element));
|
||||
// hashmap_element *temp = (hashmap_element *)calloc(2 * m->table_size, sizeof(hashmap_element));
|
||||
if (!temp)
|
||||
return MAP_OMEM;
|
||||
|
||||
|
@ -127,7 +127,6 @@ void init_isrs() {
|
||||
|
||||
extern uint32_t read_cr2();
|
||||
|
||||
|
||||
void print_regs(struct regs *r) {
|
||||
kprintf("EIP: %p CS: %x\n", r->eip, r->cs);
|
||||
kprintf("EAX: %p, EBX: %p, ECX: %p, EDX: %p\n", r->eax, r->ebx, r->ecx, r->edx);
|
||||
@ -140,7 +139,6 @@ void print_regs(struct regs *r) {
|
||||
kprintf("KSTACK: 0x%p USTACK: 0x%p TASK: %s\n", current_task->kstack, current_task->ustack, current_task->name);
|
||||
}
|
||||
|
||||
|
||||
// int i;
|
||||
|
||||
/*
|
||||
@ -391,7 +389,6 @@ void init_irqs(void) {
|
||||
|
||||
int irq_handler(struct regs *r) {
|
||||
|
||||
|
||||
if (current_task != NULL) {
|
||||
current_task->eflags = r->eflags;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __INTTYPES_H
|
||||
#define __INTTYPES_H
|
||||
|
||||
|
||||
extern void __assert_fail(const char *__assertion, const char *__file, unsigned int __line);
|
||||
#define assert(expr) ((expr ? (void)(0) : __assert_fail(#expr, __FILE__, __LINE__)))
|
||||
|
||||
|
23
ipv4.c
23
ipv4.c
@ -45,9 +45,9 @@ struct ipv4_header_t {
|
||||
struct ipv4_frag_t {
|
||||
char key[6];
|
||||
struct ipv4_header_t *first_packet;
|
||||
struct ipv4_header_t *last_packet;
|
||||
struct ipv4_header_t **middle_packets;
|
||||
int middle_packet_count;
|
||||
struct ipv4_header_t *last_packet;
|
||||
uint32_t time_created;
|
||||
};
|
||||
|
||||
@ -84,7 +84,7 @@ void ipv4_fragment_trim() {
|
||||
if (frag->last_packet != NULL) {
|
||||
dbfree(frag->last_packet, "ipv4_fragment_trim 2");
|
||||
}
|
||||
for (size_t j = 0; j < frag->middle_packet_count; j++ ) {
|
||||
for (size_t j = 0; j < frag->middle_packet_count; j++) {
|
||||
dbfree(frag->middle_packets[j], "ipv4_fragment_trim 3");
|
||||
}
|
||||
if (frag->middle_packet_count > 0) {
|
||||
@ -206,14 +206,15 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
struct ipv4_frag_t *frag;
|
||||
int error;
|
||||
int i;
|
||||
shortkey[5] = '\0';
|
||||
ptr = &shortkey[5];
|
||||
ptr = shortkey;
|
||||
|
||||
while (key > 0) {
|
||||
ptr--;
|
||||
while (key > 0 && ptr) {
|
||||
*ptr = (key % 10) + '0';
|
||||
ptr++;
|
||||
*ptr = '\0';
|
||||
key = key / 10;
|
||||
}
|
||||
|
||||
error = hashmap_get(ipv4_frag_map, shortkey, (void **)&frag);
|
||||
if (error == MAP_OK) {
|
||||
if (!(htons(iph->ipoffset) & 0x8000)) {
|
||||
@ -237,7 +238,8 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
if (frag->middle_packet_count == 0) {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbmalloc(sizeof(struct ipv4_header_t *), "ipv4 reassemble packet 3");
|
||||
} else {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1), "ipv4 reassemble packet 4");
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1),
|
||||
"ipv4 reassemble packet 4");
|
||||
}
|
||||
frag->middle_packets[frag->middle_packet_count] = (struct ipv4_header_t *)dbmalloc(htons(iph->len), "ipv4 reassemble packet 5");
|
||||
memcpy(frag->middle_packets[frag->middle_packet_count], iph, htons(iph->len));
|
||||
@ -265,7 +267,8 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
if (frag->middle_packet_count == 0) {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbmalloc(sizeof(struct ipv4_header_t *), "ipv4 reassemble packet 9");
|
||||
} else {
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1), "ipv4 reassemble packet 10");
|
||||
frag->middle_packets = (struct ipv4_header_t **)dbrealloc(frag->middle_packets, sizeof(struct ipv4_header_t *) * (frag->middle_packet_count + 1),
|
||||
"ipv4 reassemble packet 10");
|
||||
}
|
||||
frag->middle_packets[frag->middle_packet_count] = (struct ipv4_header_t *)dbmalloc(htons(iph->len), "ipv4 reassemble packet 11");
|
||||
memcpy(frag->middle_packets[frag->middle_packet_count], iph, htons(iph->len));
|
||||
@ -359,7 +362,9 @@ void ipv4_reassemble_packet(struct ether_t *ether, struct ipv4_header_t *iph) {
|
||||
for (i = 0; i < frag->middle_packet_count; i++) {
|
||||
dbfree(frag->middle_packets[i], "ipv4 reassemble packet 17");
|
||||
}
|
||||
dbfree(frag->middle_packets, "ipv4 reassemble packet 18");
|
||||
if (frag->middle_packet_count > 0) {
|
||||
dbfree(frag->middle_packets, "ipv4 reassemble packet 18");
|
||||
}
|
||||
dbfree(frag, "ipv4 reassemble packet 19");
|
||||
}
|
||||
|
||||
|
10
kernel.c
10
kernel.c
@ -32,9 +32,9 @@ extern int last_syscall;
|
||||
extern const char *db_malloc_caller[];
|
||||
|
||||
void __assert_fail(const char *__assertion, const char *__file, unsigned int __line) {
|
||||
kprintf("ASSERTION FAILED\n");
|
||||
kprintf("%s\n", __assertion);
|
||||
kprintf("%s: line %d\n\n", __file, __line);
|
||||
kprintf("ASSERTION FAILED\n");
|
||||
kprintf("%s\n", __assertion);
|
||||
kprintf("%s: line %d\n\n", __file, __line);
|
||||
}
|
||||
|
||||
void abort(void) {
|
||||
@ -44,8 +44,8 @@ void abort(void) {
|
||||
kprintf("DBMALLOC[%d]. %s\n", i, db_malloc_caller[i]);
|
||||
}
|
||||
}
|
||||
kprintf("PID: %d (%s)\n", current_task->pid, current_task->name);
|
||||
kprintf("LAST SYSCALL %d\n", last_syscall);
|
||||
kprintf("PID: %d (%s)\n", current_task->pid, current_task->name);
|
||||
kprintf("LAST SYSCALL %d\n", last_syscall);
|
||||
while (1)
|
||||
__asm__ volatile("hlt");
|
||||
}
|
||||
|
6
malloc.c
6
malloc.c
@ -1435,7 +1435,7 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int);
|
||||
#endif /* _MSC_VER */
|
||||
#if !NO_MALLOC_STATS
|
||||
#include "console.h" /* for printing in malloc_stats */
|
||||
#endif /* NO_MALLOC_STATS */
|
||||
#endif /* NO_MALLOC_STATS */
|
||||
#ifndef LACKS_ERRNO_H
|
||||
#include <errno.h> /* for MALLOC_FAILURE_ACTION */
|
||||
#endif /* LACKS_ERRNO_H */
|
||||
@ -1445,8 +1445,8 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int);
|
||||
#define assert(x) \
|
||||
if (!(x)) \
|
||||
ABORT
|
||||
#else /* ABORT_ON_ASSERT_FAILURE */
|
||||
//QUINN.. assert is in inttypes
|
||||
#else /* ABORT_ON_ASSERT_FAILURE */
|
||||
// QUINN.. assert is in inttypes
|
||||
#endif /* ABORT_ON_ASSERT_FAILURE */
|
||||
#else /* DEBUG */
|
||||
#ifndef assert
|
||||
|
27
memory.c
27
memory.c
@ -64,8 +64,8 @@ static __inline__ uint32_t round_up_to_page(uint32_t addr) {
|
||||
extern uint8_t *endkernel;
|
||||
|
||||
void init_mem(multiboot_info_t *mbd) {
|
||||
//int available = 0;
|
||||
//int total = 0;
|
||||
// int available = 0;
|
||||
// int total = 0;
|
||||
uint32_t mem_end;
|
||||
int i;
|
||||
|
||||
@ -80,9 +80,9 @@ void init_mem(multiboot_info_t *mbd) {
|
||||
pages_above_kernel = mmap->len / PAGE_SIZE;
|
||||
end_free_mem = (uint8_t *)((uint32_t)mmap->addr + (uint32_t)mmap->len);
|
||||
}
|
||||
//available += mmap->len;
|
||||
// available += mmap->len;
|
||||
}
|
||||
//total += mmap->len;
|
||||
// total += mmap->len;
|
||||
|
||||
mmap = (multiboot_memory_map_t *)((uint32_t)mmap + mmap->size + sizeof(uint32_t));
|
||||
}
|
||||
@ -170,7 +170,7 @@ int mem_cpy_pages(struct task_t *old_task, struct task_t *new_task) {
|
||||
new_task->user_pages_cnt = old_task->user_pages_cnt;
|
||||
|
||||
for (i = 0; i < old_task->user_pages_cnt; i++) {
|
||||
//virt = i * 0x1000 + 0x40000000;
|
||||
// virt = i * 0x1000 + 0x40000000;
|
||||
new_task->user_pages[i] = (uint32_t)mem_alloc_pid(new_task->pid);
|
||||
new_task->user_pages_virt[i] = old_task->user_pages_virt[i];
|
||||
mem_map_page(new_task->user_pages[i], (uint32_t)fake_tab, 7);
|
||||
@ -197,7 +197,7 @@ int mem_cpy_pages(struct task_t *old_task, struct task_t *new_task) {
|
||||
}
|
||||
|
||||
// copy environment
|
||||
//virt = 0xf0000000;
|
||||
// virt = 0xf0000000;
|
||||
for (i = 0; i < 64; i++) {
|
||||
virt = 0xf0000000 + (i * 0x1000);
|
||||
new_task->user_env_pages[i] = (uint32_t)mem_alloc_pid(new_task->pid);
|
||||
@ -554,7 +554,8 @@ char *mem_alloc_user_page(uint32_t virt) {
|
||||
current_task->user_pages_virt = (uint32_t *)dbmalloc(current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 2");
|
||||
} else {
|
||||
current_task->user_pages = (uint32_t *)dbrealloc(current_task->user_pages, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 3");
|
||||
current_task->user_pages_virt = (uint32_t *)dbrealloc(current_task->user_pages_virt, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 4");
|
||||
current_task->user_pages_virt =
|
||||
(uint32_t *)dbrealloc(current_task->user_pages_virt, current_task->user_pages_cnt * sizeof(uint32_t), "mem alloc user page 4");
|
||||
}
|
||||
|
||||
current_task->user_pages[current_task->user_pages_cnt - 1] = (uint32_t)mem_alloc();
|
||||
@ -682,7 +683,7 @@ struct db_tail {
|
||||
|
||||
void *dbmalloc(int size, const char *caller) {
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
@ -703,14 +704,14 @@ void *dbrealloc(void *ptr, int size, const char *caller) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
|
||||
struct db_header *data = (struct db_header *)((char *)ptr - sizeof(struct db_header));
|
||||
|
||||
assert(data->magic == 0xdeadbeef && data->tail->magic == 0xcafefeed);
|
||||
|
||||
|
||||
struct db_header *dtmp = (struct db_header *)realloc(data, size + sizeof(struct db_header) + sizeof(struct db_tail));
|
||||
if (!dtmp) {
|
||||
return NULL;
|
||||
@ -744,13 +745,13 @@ void dbfree(void *ptr, const char *caller) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < 20; i++) {
|
||||
db_malloc_caller[i-1] = db_malloc_caller[i];
|
||||
db_malloc_caller[i - 1] = db_malloc_caller[i];
|
||||
}
|
||||
db_malloc_caller[19] = caller;
|
||||
|
||||
struct db_header *data = (struct db_header *)((char *)ptr - sizeof(struct db_header));
|
||||
|
||||
if(data->magic != 0xdeadbeef || data->tail->magic != 0xcafefeed) {
|
||||
if (data->magic != 0xdeadbeef || data->tail->magic != 0xcafefeed) {
|
||||
kprintf("BAD MAGIC ! %p %p\n", data->magic, ptr);
|
||||
kprintf("CALLED BY %s\n", caller);
|
||||
abort();
|
||||
|
11
minix.c
11
minix.c
@ -218,8 +218,8 @@ int minix_add_directory_entry(struct vfs_device_t *device, struct minix_inode *d
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct minix_inode *minix_new_node(struct vfs_device_t *device, struct minix_inode *dirp, uint32_t dir_ino, char *name, uint16_t mode,
|
||||
uint32_t z0, uint32_t *new_ino) {
|
||||
static struct minix_inode *minix_new_node(struct vfs_device_t *device, struct minix_inode *dirp, uint32_t dir_ino, char *name, uint16_t mode, uint32_t z0,
|
||||
uint32_t *new_ino) {
|
||||
struct minix_inode *new_inode;
|
||||
uint32_t ino;
|
||||
|
||||
@ -892,7 +892,6 @@ struct minix_inode *minix_get_inode(struct vfs_device_t *device, int ino) {
|
||||
int inodes_per_block = mdata->sb.s_blocksize / sizeof(struct minix_inode);
|
||||
uint32_t block;
|
||||
|
||||
|
||||
char *buffer = (char *)dbmalloc(mdata->sb.s_blocksize, "minix get inode 1");
|
||||
|
||||
if (!buffer) {
|
||||
@ -1404,8 +1403,7 @@ int minix_read_data(struct vfs_device_t *device, struct minix_file_info *info, c
|
||||
}
|
||||
} else if ((device->device & 0xff00) == 0x100) {
|
||||
for (j = block_start; j < block_start + blockcount; j++) {
|
||||
hd_read_block((device->device & 0xff), minix_read_map(device, inode, (uint64_t)(j * mdata->sb.s_blocksize)), tempbuffer,
|
||||
mdata->sb.s_blocksize);
|
||||
hd_read_block((device->device & 0xff), minix_read_map(device, inode, (uint64_t)(j * mdata->sb.s_blocksize)), tempbuffer, mdata->sb.s_blocksize);
|
||||
if (j == block_start) {
|
||||
if (count + block_offset > mdata->sb.s_blocksize) {
|
||||
memcpy(buffer, &tempbuffer[block_offset], mdata->sb.s_blocksize - block_offset);
|
||||
@ -1436,8 +1434,7 @@ int minix_read_data(struct vfs_device_t *device, struct minix_file_info *info, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset,
|
||||
uint64_t *newoffset) {
|
||||
int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset, uint64_t *newoffset) {
|
||||
struct minix_inode *inode = minix_get_inode(device, info->inode);
|
||||
char *buffer2;
|
||||
int dirlen = minix_read_entire_file(device, inode, &buffer2);
|
||||
|
3
minix.h
3
minix.h
@ -55,8 +55,7 @@ struct minix_data {
|
||||
#define NO_BLOCK 0
|
||||
|
||||
extern struct minix_inode *minix_get_inode(struct vfs_device_t *device, int ino);
|
||||
extern int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset,
|
||||
uint64_t *newoffset);
|
||||
extern int minix_get_dents(struct vfs_device_t *device, struct minix_file_info *info, char *buffer, int len, uint64_t offset, uint64_t *newoffset);
|
||||
extern struct minix_file_info *minix_check_if_exists(struct vfs_device_t *device, const char *path, int type);
|
||||
extern int minix_create_file(struct vfs_device_t *device, char *path);
|
||||
extern void minix_trunc_file(struct vfs_device_t *device, struct minix_file_info *finfo);
|
||||
|
4
mouse.c
4
mouse.c
@ -12,8 +12,8 @@ extern void ps2_handler(struct regs *r);
|
||||
|
||||
uint8_t mouse_cycle = 0; // uint8_t
|
||||
uint8_t mouse_byte[4]; // signed char
|
||||
short mouse_x = 0; // signed char
|
||||
short mouse_y = 0; // signed char
|
||||
short mouse_x = 0; // signed char
|
||||
short mouse_y = 0; // signed char
|
||||
char middle_btn = 0;
|
||||
char left_btn = 0;
|
||||
char right_btn = 0;
|
||||
|
8
pata.c
8
pata.c
@ -29,7 +29,7 @@ void init_pata() {
|
||||
if (devcount == 1) {
|
||||
ide_devices = (struct ide_dev **)dbmalloc(sizeof(struct ide_dev *), "init pata 1");
|
||||
} else {
|
||||
ide_devices = (struct ide_dev **)dbrealloc(ide_devices, sizeof(struct ide_dev *) * devcount , "init pata 4");
|
||||
ide_devices = (struct ide_dev **)dbrealloc(ide_devices, sizeof(struct ide_dev *) * devcount, "init pata 4");
|
||||
}
|
||||
|
||||
ide_device = (struct ide_dev *)dbmalloc(sizeof(struct ide_dev), "init pata 3");
|
||||
@ -267,8 +267,7 @@ void ide_wait_irq() {
|
||||
}
|
||||
|
||||
void ide_irq_isr(struct regs *r) { ide_irq_invoked = 1; }
|
||||
uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects,
|
||||
uint16_t selector, uint32_t edi) {
|
||||
uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects, uint16_t selector, uint32_t edi) {
|
||||
uint32_t channel = device->ide_devices[drive].channel; // Read the Channel.
|
||||
uint32_t slavebit = device->ide_devices[drive].drive; // Read the Drive [Master/Slave]
|
||||
|
||||
@ -404,8 +403,7 @@ uint8_t ide_ata_dma_access(struct ide_dev *device, uint8_t direction, uint8_t dr
|
||||
ide_write(device, channel, ATA_REG_CONTROL, device->channels[channel].nIEN = (ide_irq_invoked = 0x0) + 0x2);
|
||||
return 0;
|
||||
}
|
||||
uint8_t ide_ata_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects,
|
||||
uint16_t selector, uint32_t edi) {
|
||||
uint8_t ide_ata_access(struct ide_dev *device, uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects, uint16_t selector, uint32_t edi) {
|
||||
uint8_t lba_mode /* 0: CHS, 1:LBA28, 2: LBA48 */, dma /* 0: No DMA, 1: DMA */, cmd;
|
||||
uint8_t lba_io[6];
|
||||
uint32_t channel = device->ide_devices[drive].channel; // Read the Channel.
|
||||
|
10
pata.h
10
pata.h
@ -100,10 +100,10 @@ struct ide_dev {
|
||||
struct pci_device *pci_dev;
|
||||
int use_dma;
|
||||
struct channel {
|
||||
uint16_t base; // I/O Base.
|
||||
uint16_t ctrl; // Control Base
|
||||
uint16_t base; // I/O Base.
|
||||
uint16_t ctrl; // Control Base
|
||||
uint32_t bmide; // Bus Master IDE
|
||||
uint8_t nIEN; // nIEN (No Interrupt);
|
||||
uint8_t nIEN; // nIEN (No Interrupt);
|
||||
} channels[2];
|
||||
|
||||
struct ide_device {
|
||||
@ -114,8 +114,8 @@ struct ide_dev {
|
||||
uint16_t type; // 0: ATA, 1:ATAPI.
|
||||
uint16_t sign; // Drive Signature
|
||||
uint16_t capabilities; // Features.
|
||||
uint32_t commandsets; // Command Sets Supported.
|
||||
uint32_t size; // Size in Sectors.
|
||||
uint32_t commandsets; // Command Sets Supported.
|
||||
uint32_t size; // Size in Sectors.
|
||||
uint8_t model[41]; // Model in string.
|
||||
struct prdt_t *dma_prdt;
|
||||
uint32_t dma_prdt_phys;
|
||||
|
4
pci.h
4
pci.h
@ -44,8 +44,8 @@ struct pci_device {
|
||||
uint8_t type[6];
|
||||
uint8_t irq;
|
||||
|
||||
uint8_t cap[6]; // Maps cap type to offset within the pci config space.
|
||||
uint8_t cap_bar[6]; // Maps cap type to their BAR number
|
||||
uint8_t cap[6]; // Maps cap type to offset within the pci config space.
|
||||
uint8_t cap_bar[6]; // Maps cap type to their BAR number
|
||||
uint32_t cap_off[6]; // Map cap type to offset within bar
|
||||
};
|
||||
|
||||
|
16
schedule.c
16
schedule.c
@ -453,14 +453,14 @@ void sched_new_ktask(void *func, void *ctxt) {
|
||||
*--stack_setup = 0;
|
||||
*--stack_setup = 0;
|
||||
|
||||
*--stack_setup = (uint32_t)func; // EAX
|
||||
*--stack_setup = 0; // ECX
|
||||
*--stack_setup = 0; // EDX
|
||||
*--stack_setup = (uint32_t)ctxt; // EBX
|
||||
*--stack_setup = 0; // Just an offset, no value
|
||||
*--stack_setup = new_task->esp - 8; // EBP
|
||||
*--stack_setup = 0; // ESI
|
||||
*--stack_setup = 0; // EDI
|
||||
*--stack_setup = (uint32_t)func; // EAX
|
||||
*--stack_setup = 0; // ECX
|
||||
*--stack_setup = 0; // EDX
|
||||
*--stack_setup = (uint32_t)ctxt; // EBX
|
||||
*--stack_setup = 0; // Just an offset, no value
|
||||
*--stack_setup = new_task->esp - 8; // EBP
|
||||
*--stack_setup = 0; // ESI
|
||||
*--stack_setup = 0; // EDI
|
||||
|
||||
*--stack_setup = 0x10; // DS
|
||||
*--stack_setup = 0x10; // ES
|
||||
|
6
socket.c
6
socket.c
@ -128,7 +128,7 @@ int socket_queue(struct socket_t *sock, uint8_t *payload, uint32_t len, uint16_t
|
||||
outpacket->flags = flags;
|
||||
if (len > 0) {
|
||||
outpacket->data = (uint8_t *)dbmalloc(len, "socket queue 2");
|
||||
if (!outpacket->data)
|
||||
if (!outpacket->data)
|
||||
return -1;
|
||||
memcpy(outpacket->data, payload, len);
|
||||
}
|
||||
@ -334,7 +334,7 @@ int socket_read(uint32_t serial, char *buffer, int len) {
|
||||
struct tcp_data_t *data = NULL;
|
||||
|
||||
uint32_t size_to_read;
|
||||
|
||||
|
||||
int flag_psh = 0;
|
||||
|
||||
sock->offset = 0;
|
||||
@ -578,7 +578,7 @@ void socket_doclose(struct socket_t *sock) {
|
||||
for (i = 0; i < ptr_vector_len(&sockets); i++) {
|
||||
struct socket_t *s = (struct socket_t *)ptr_vector_get(&sockets, i);
|
||||
if (s == sock) {
|
||||
|
||||
|
||||
ptr_vector_del(&sockets, i);
|
||||
|
||||
socket_clear_port_bitmap(sock->port_recv);
|
||||
|
4
string.c
4
string.c
@ -12,7 +12,7 @@ void memset(char *ptr, char value, int len) {
|
||||
|
||||
void *memmove(void *dest, const void *src, uint32_t n) {
|
||||
assert(dest != NULL && src != NULL);
|
||||
|
||||
|
||||
char *pDest = (char *)dest;
|
||||
const char *pSrc = (const char *)src;
|
||||
// allocate memory for tmp array
|
||||
@ -98,7 +98,7 @@ int memcmp(const uint8_t *m1, const uint8_t *m2, int size) {
|
||||
|
||||
int strncmp(const char *s1, const char *s2, int n) {
|
||||
assert(s1 != NULL && s2 != NULL);
|
||||
|
||||
|
||||
while ((*s1) && (*s1 == *s2) && n > 0) {
|
||||
--n;
|
||||
++s1;
|
||||
|
2
tcp.c
2
tcp.c
@ -172,7 +172,7 @@ void tcp_process_packet(struct ether_t *ether, uint32_t dest, uint32_t src, stru
|
||||
socket_doclose(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
struct tcp_data_t *data;
|
||||
|
||||
data = (struct tcp_data_t *)dbmalloc(sizeof(struct tcp_data_t), "tcp process packet 1");
|
||||
|
12
vfs.h
12
vfs.h
@ -39,13 +39,13 @@ struct quinn_pipe_t {
|
||||
};
|
||||
|
||||
struct stat {
|
||||
uint16_t st_dev; // ID of device containing file
|
||||
uint16_t st_dev; // ID of device containing file
|
||||
uint32_t st_ino; // file serial number
|
||||
uint16_t st_mode; // mode of file (see below)
|
||||
uint16_t st_nlink; // number of links to the file
|
||||
uint16_t st_uid; // user ID of file
|
||||
uint16_t st_gid; // group ID of file
|
||||
uint16_t st_rdev; // device ID (if file is character or block special)
|
||||
uint16_t st_mode; // mode of file (see below)
|
||||
uint16_t st_nlink; // number of links to the file
|
||||
uint16_t st_uid; // user ID of file
|
||||
uint16_t st_gid; // group ID of file
|
||||
uint16_t st_rdev; // device ID (if file is character or block special)
|
||||
uint32_t st_size; // file size in bytes (if file is a regular file)
|
||||
uint32_t st_atime; // time of last access
|
||||
uint32_t st_mtime; // time of last data modification
|
||||
|
Loading…
x
Reference in New Issue
Block a user