Changeset a35b458 in mainline for kernel/genarch
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/genarch
- Files:
-
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/genarch/fb/fb.h
r3061bc1 ra35b458 46 46 /** Physical address of the framebuffer device. */ 47 47 uintptr_t addr; 48 48 49 49 /** 50 50 * Address where the first (top left) pixel is mapped, … … 52 52 */ 53 53 unsigned int offset; 54 54 55 55 /** Screen width in pixels. */ 56 56 unsigned int x; 57 57 58 58 /** Screen height in pixels. */ 59 59 unsigned int y; 60 60 61 61 /** Bytes per one scanline. */ 62 62 unsigned int scan; 63 63 64 64 /** Color model. */ 65 65 visual_t visual; -
kernel/genarch/include/genarch/kbrd/kbrd.h
r3061bc1 ra35b458 43 43 typedef struct { 44 44 thread_t *thread; 45 45 46 46 indev_t *sink; 47 47 indev_t raw; 48 48 49 49 SPINLOCK_DECLARE(keylock); /**< keylock protects keyflags and lockflags. */ 50 50 volatile unsigned int keyflags; /**< Tracking of multiple keypresses. */ -
kernel/genarch/include/genarch/ofw/ebus.h
r3061bc1 ra35b458 45 45 uint32_t child_base; 46 46 uint32_t parent_space; 47 47 48 48 /* Group phys.mid and phys.lo together */ 49 49 uint64_t parent_base; -
kernel/genarch/include/genarch/ofw/ofw_tree.h
r3061bc1 ra35b458 49 49 struct ofw_tree_node *peer; 50 50 struct ofw_tree_node *child; 51 51 52 52 phandle node_handle; /**< Old OpenFirmware node handle. */ 53 53 54 54 char *da_name; /**< Disambigued name. */ 55 55 56 56 size_t properties; /**< Number of properties. */ 57 57 ofw_tree_property_t *property; 58 58 59 59 /** 60 60 * Pointer to a structure representing respective device. -
kernel/genarch/include/genarch/ofw/pci.h
r3061bc1 ra35b458 38 38 /* Needs to be masked to obtain pure space id */ 39 39 uint32_t space; 40 40 41 41 /* Group phys.mid and phys.lo together */ 42 42 uint64_t addr; … … 46 46 typedef struct { 47 47 uint32_t space; 48 48 49 49 /* Group phys.mid and phys.lo together */ 50 50 uint64_t child_base; -
kernel/genarch/include/genarch/srln/srln.h
r3061bc1 ra35b458 42 42 typedef struct { 43 43 thread_t *thread; 44 44 45 45 indev_t *sink; 46 46 indev_t raw; -
kernel/genarch/src/acpi/acpi.c
r3061bc1 ra35b458 69 69 uint8_t sum = 0; 70 70 uint32_t i; 71 71 72 72 for (i = 0; i < 20; i++) 73 73 sum = (uint8_t) (sum + _rsdp[i]); 74 74 75 75 if (sum) 76 76 return 0; /* bad checksum */ 77 77 78 78 if (rsdp->revision == 0) 79 79 return 1; /* ACPI 1.0 */ 80 80 81 81 for (; i < rsdp->length; i++) 82 82 sum = (uint8_t) (sum + _rsdp[i]); 83 83 84 84 return !sum; 85 85 } … … 90 90 uint8_t sum = 0; 91 91 unsigned int i; 92 92 93 93 for (i = 0; i < hdr->length; i++) 94 94 sum = (uint8_t) (sum + sdt[i]); 95 95 96 96 return !sum; 97 97 } … … 109 109 vsdt = (struct acpi_sdt_header *) km_map((uintptr_t) psdt, 110 110 vhdr->length, PAGE_WRITE | PAGE_NOT_CACHEABLE); 111 111 112 112 // TODO: do not leak vtmp 113 113 … … 121 121 size_t cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header)) 122 122 / sizeof(uint32_t); 123 123 124 124 for (i = 0; i < cnt; i++) { 125 125 for (j = 0; j < sizeof(signature_map) … … 127 127 struct acpi_sdt_header *hdr = 128 128 (struct acpi_sdt_header *) (sysarg_t) acpi_rsdt->entry[i]; 129 129 130 130 struct acpi_sdt_header *vhdr = map_sdt(hdr); 131 131 if (CMP_SIGNATURE(vhdr->signature, signature_map[j].signature)) { 132 132 if (!acpi_sdt_check((uint8_t *) vhdr)) 133 133 break; 134 134 135 135 *signature_map[j].sdt_ptr = vhdr; 136 136 LOG("%p: ACPI %s", *signature_map[j].sdt_ptr, … … 147 147 size_t cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header)) 148 148 / sizeof(uint64_t); 149 149 150 150 for (i = 0; i < cnt; i++) { 151 151 for (j = 0; j < sizeof(signature_map) … … 153 153 struct acpi_sdt_header *hdr = 154 154 (struct acpi_sdt_header *) ((uintptr_t) acpi_xsdt->entry[i]); 155 155 156 156 struct acpi_sdt_header *vhdr = map_sdt(hdr); 157 157 if (CMP_SIGNATURE(vhdr->signature, signature_map[j].signature)) { 158 158 if (!acpi_sdt_check((uint8_t *) vhdr)) 159 159 break; 160 160 161 161 *signature_map[j].sdt_ptr = vhdr; 162 162 LOG("%p: ACPI %s", *signature_map[j].sdt_ptr, … … 174 174 unsigned int length[2] = { 1024, 128 * 1024 }; 175 175 uint64_t *sig = (uint64_t *) RSDP_SIGNATURE; 176 176 177 177 /* 178 178 * Find Root System Description Pointer … … 180 180 * 2. search 128K starting at 0xe0000 181 181 */ 182 182 183 183 addr[0] = (uint8_t *) PA2KA(ebda); 184 184 for (i = (ebda ? 0 : 1); i < 2; i++) { … … 191 191 } 192 192 } 193 193 194 194 return; 195 195 196 196 rsdp_found: 197 197 LOG("%p: ACPI Root System Description Pointer", acpi_rsdp); 198 198 199 199 uintptr_t acpi_rsdt_p = (uintptr_t) acpi_rsdp->rsdt_address; 200 200 uintptr_t acpi_xsdt_p = 0; … … 202 202 if (acpi_rsdp->revision) 203 203 acpi_xsdt_p = (uintptr_t) acpi_rsdp->xsdt_address; 204 204 205 205 if (acpi_rsdt_p) 206 206 acpi_rsdt = (struct acpi_rsdt *) map_sdt( 207 207 (struct acpi_sdt_header *) acpi_rsdt_p); 208 208 209 209 if (acpi_xsdt_p) 210 210 acpi_xsdt = (struct acpi_xsdt *) map_sdt( 211 211 (struct acpi_sdt_header *) acpi_xsdt_p); 212 212 213 213 if ((acpi_rsdt) && (!acpi_sdt_check((uint8_t *) acpi_rsdt))) { 214 214 log(LF_ARCH, LVL_ERROR, "RSDT: bad checksum"); 215 215 return; 216 216 } 217 217 218 218 if ((acpi_xsdt) && (!acpi_sdt_check((uint8_t *) acpi_xsdt))) { 219 219 log(LF_ARCH, LVL_ERROR, "XSDT: bad checksum"); 220 220 return; 221 221 } 222 222 223 223 if (acpi_xsdt) 224 224 configure_via_xsdt(); -
kernel/genarch/src/acpi/madt.c
r3061bc1 ra35b458 83 83 { 84 84 assert(i < madt_l_apic_entry_cnt); 85 85 86 86 return ((struct madt_l_apic *) 87 87 madt_entries_index[madt_l_apic_entry_index + i])->apic_id; … … 91 91 { 92 92 assert(i < madt_l_apic_entry_cnt); 93 93 94 94 /* 95 95 * FIXME: The current local APIC driver limits usable … … 99 99 if (i > 7) 100 100 return false; 101 101 102 102 return ((struct madt_l_apic *) 103 103 madt_entries_index[madt_l_apic_entry_index + i])->flags & 0x1; … … 107 107 { 108 108 assert(i < madt_l_apic_entry_cnt); 109 109 110 110 return ((struct madt_l_apic *) 111 111 madt_entries_index[madt_l_apic_entry_index + i])->apic_id == … … 117 117 if (irq >= sizeof(isa_irq_map) / sizeof(int)) 118 118 return (int) irq; 119 119 120 120 return isa_irq_map[irq]; 121 121 } … … 135 135 uint8_t typea = (*((struct madt_apic_header **) a))->type; 136 136 uint8_t typeb = (*((struct madt_apic_header **) b))->type; 137 137 138 138 if (typea > typeb) 139 139 return 1; 140 140 141 141 if (typea < typeb) 142 142 return -1; 143 143 144 144 return 0; 145 145 } … … 149 149 if (madt_l_apic_entry_cnt == 0) 150 150 madt_l_apic_entry_index = i; 151 151 152 152 madt_l_apic_entry_cnt++; 153 153 154 154 if (!(la->flags & 0x1)) { 155 155 /* Processor is unusable, skip it. */ 156 156 return; 157 157 } 158 158 159 159 apic_id_mask |= 1 << la->apic_id; 160 160 } … … 169 169 /* Currently not supported */ 170 170 } 171 171 172 172 madt_io_apic_entry_cnt++; 173 173 } … … 177 177 { 178 178 assert(override->source < sizeof(isa_irq_map) / sizeof(int)); 179 179 180 180 isa_irq_map[override->source] = override->global_int; 181 181 } … … 186 186 (((uint8_t *) acpi_madt) + acpi_madt->header.length); 187 187 struct madt_apic_header *hdr; 188 188 189 189 l_apic = (uint32_t *) (sysarg_t) acpi_madt->l_apic_address; 190 190 191 191 /* Count MADT entries */ 192 192 unsigned int madt_entries_index_cnt = 0; … … 194 194 hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length)) 195 195 madt_entries_index_cnt++; 196 196 197 197 /* Create MADT APIC entries index array */ 198 198 madt_entries_index = (struct madt_apic_header **) … … 201 201 if (!madt_entries_index) 202 202 panic("Memory allocation error."); 203 203 204 204 size_t i = 0; 205 205 206 206 for (hdr = acpi_madt->apic_header; hdr < end; 207 207 hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length)) { … … 209 209 i++; 210 210 } 211 211 212 212 /* Sort MADT index structure */ 213 213 if (!gsort(madt_entries_index, madt_entries_index_cnt, 214 214 sizeof(struct madt_apic_header *), madt_cmp, NULL)) 215 215 panic("Sorting error."); 216 216 217 217 /* Parse MADT entries */ 218 218 for (i = 0; i < madt_entries_index_cnt; i++) { 219 219 hdr = madt_entries_index[i]; 220 220 221 221 switch (hdr->type) { 222 222 case MADT_L_APIC: … … 245 245 "MADT: Skipping reserved entry (type=%" PRIu8 ")", 246 246 hdr->type); 247 247 248 248 if (hdr->type >= MADT_RESERVED_OEM_BEGIN) 249 249 log(LF_ARCH, LVL_NOTE, 250 250 "MADT: Skipping OEM entry (type=%" PRIu8 ")", 251 251 hdr->type); 252 252 253 253 break; 254 254 } 255 255 } 256 256 257 257 if (madt_l_apic_entry_cnt > 0) 258 258 config.cpu_count = madt_l_apic_entry_cnt; -
kernel/genarch/src/ddi/ddi-bitmap.c
r3061bc1 ra35b458 62 62 if (elements > IO_PORTS) 63 63 return ENOENT; 64 64 65 65 if (task->arch.iomap.elements < elements) { 66 66 /* 67 67 * The I/O permission bitmap is too small and needs to be grown. 68 68 */ 69 69 70 70 void *store = malloc(bitmap_size(elements), FRAME_ATOMIC); 71 71 if (!store) 72 72 return ENOMEM; 73 73 74 74 bitmap_t oldiomap; 75 75 bitmap_initialize(&oldiomap, task->arch.iomap.elements, 76 76 task->arch.iomap.bits); 77 77 78 78 bitmap_initialize(&task->arch.iomap, elements, store); 79 79 80 80 /* 81 81 * Mark the new range inaccessible. … … 83 83 bitmap_set_range(&task->arch.iomap, oldiomap.elements, 84 84 elements - oldiomap.elements); 85 85 86 86 /* 87 87 * In case there really existed smaller iomap, … … 91 91 bitmap_copy(&task->arch.iomap, &oldiomap, 92 92 oldiomap.elements); 93 93 94 94 free(oldiomap.bits); 95 95 } 96 96 } 97 97 98 98 /* 99 99 * Enable the range and we are done. 100 100 */ 101 101 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size); 102 102 103 103 /* 104 104 * Increment I/O Permission bitmap generation counter. 105 105 */ 106 106 task->arch.iomapver++; 107 107 108 108 return EOK; 109 109 } … … 125 125 if (elements > IO_PORTS) 126 126 return ENOENT; 127 127 128 128 if (ioaddr >= task->arch.iomap.elements) 129 129 return EINVAL; … … 136 136 */ 137 137 bitmap_set_range(&task->arch.iomap, (size_t) ioaddr, size); 138 138 139 139 /* 140 140 * Increment I/O Permission bitmap generation counter. 141 141 */ 142 142 task->arch.iomapver++; 143 143 144 144 return 0; 145 145 } -
kernel/genarch/src/drivers/dsrln/dsrlnin.c
r3061bc1 ra35b458 50 50 dsrlnin_instance_t *instance = irq->instance; 51 51 dsrlnin_t *dev = instance->dsrlnin; 52 52 53 53 indev_push_character(instance->srlnin, pio_read_8(&dev->data)); 54 54 } … … 61 61 instance->dsrlnin = dev; 62 62 instance->srlnin = NULL; 63 63 64 64 irq_initialize(&instance->irq); 65 65 instance->irq.inr = inr; … … 68 68 instance->irq.instance = instance; 69 69 } 70 70 71 71 return instance; 72 72 } … … 76 76 assert(instance); 77 77 assert(srlnin); 78 78 79 79 instance->srlnin = srlnin; 80 80 irq_register(&instance->irq); -
kernel/genarch/src/drivers/dsrln/dsrlnout.c
r3061bc1 ra35b458 52 52 { 53 53 dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data; 54 54 55 55 if ((!instance->parea.mapped) || (console_override)) { 56 56 if (ascii_check(ch)) … … 73 73 if (!dsrlndev) 74 74 return NULL; 75 75 76 76 dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), 77 77 FRAME_ATOMIC); … … 80 80 return NULL; 81 81 } 82 82 83 83 outdev_initialize("dsrlndev", dsrlndev, &dsrlndev_ops); 84 84 dsrlndev->data = instance; 85 85 86 86 instance->base = base; 87 87 link_initialize(&instance->parea.link); … … 91 91 instance->parea.mapped = false; 92 92 ddi_parea_register(&instance->parea); 93 93 94 94 if (!fb_exported) { 95 95 /* … … 101 101 sysinfo_set_item_val("fb.kind", NULL, 3); 102 102 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(base)); 103 103 104 104 fb_exported = true; 105 105 } 106 106 107 107 return dsrlndev; 108 108 } -
kernel/genarch/src/drivers/ega/ega.c
r3061bc1 ra35b458 63 63 typedef struct { 64 64 IRQ_SPINLOCK_DECLARE(lock); 65 65 66 66 parea_t parea; 67 67 68 68 uint32_t cursor; 69 69 uint8_t *addr; … … 86 86 if ((ch >= 0x0000) && (ch <= 0x007f)) 87 87 return ch; 88 88 89 89 if (ch == 0x00a0) 90 90 return 255; 91 91 92 92 if (ch == 0x00a1) 93 93 return 173; 94 94 95 95 if ((ch >= 0x00a2) && (ch <= 0x00a3)) 96 96 return (ch - 7); 97 97 98 98 if (ch == 0x00a5) 99 99 return 157; 100 100 101 101 if (ch == 0x00aa) 102 102 return 166; 103 103 104 104 if (ch == 0x00ab) 105 105 return 174; 106 106 107 107 if (ch == 0x00ac) 108 108 return 170; 109 109 110 110 if (ch == 0x00b0) 111 111 return 248; 112 112 113 113 if (ch == 0x00b1) 114 114 return 241; 115 115 116 116 if (ch == 0x00b2) 117 117 return 253; 118 118 119 119 if (ch == 0x00b5) 120 120 return 230; 121 121 122 122 if (ch == 0x00b7) 123 123 return 250; 124 124 125 125 if (ch == 0x00ba) 126 126 return 167; 127 127 128 128 if (ch == 0x00bb) 129 129 return 175; 130 130 131 131 if (ch == 0x00bc) 132 132 return 172; 133 133 134 134 if (ch == 0x00bd) 135 135 return 171; 136 136 137 137 if (ch == 0x00bf) 138 138 return 168; 139 139 140 140 if ((ch >= 0x00c4) && (ch <= 0x00c5)) 141 141 return (ch - 54); 142 142 143 143 if (ch == 0x00c6) 144 144 return 146; 145 145 146 146 if (ch == 0x00c7) 147 147 return 128; 148 148 149 149 if (ch == 0x00c9) 150 150 return 144; 151 151 152 152 if (ch == 0x00d1) 153 153 return 165; 154 154 155 155 if (ch == 0x00d6) 156 156 return 153; 157 157 158 158 if (ch == 0x00dc) 159 159 return 154; 160 160 161 161 if (ch == 0x00df) 162 162 return 225; 163 163 164 164 if (ch == 0x00e0) 165 165 return 133; 166 166 167 167 if (ch == 0x00e1) 168 168 return 160; 169 169 170 170 if (ch == 0x00e2) 171 171 return 131; 172 172 173 173 if (ch == 0x00e4) 174 174 return 132; 175 175 176 176 if (ch == 0x00e5) 177 177 return 134; 178 178 179 179 if (ch == 0x00e6) 180 180 return 145; 181 181 182 182 if (ch == 0x00e7) 183 183 return 135; 184 184 185 185 if (ch == 0x00e8) 186 186 return 138; 187 187 188 188 if (ch == 0x00e9) 189 189 return 130; 190 190 191 191 if ((ch >= 0x00ea) && (ch <= 0x00eb)) 192 192 return (ch - 98); 193 193 194 194 if (ch == 0x00ec) 195 195 return 141; 196 196 197 197 if (ch == 0x00ed) 198 198 return 161; 199 199 200 200 if (ch == 0x00ee) 201 201 return 140; 202 202 203 203 if (ch == 0x00ef) 204 204 return 139; 205 205 206 206 if (ch == 0x00f1) 207 207 return 164; 208 208 209 209 if (ch == 0x00f2) 210 210 return 149; 211 211 212 212 if (ch == 0x00f3) 213 213 return 162; 214 214 215 215 if (ch == 0x00f4) 216 216 return 147; 217 217 218 218 if (ch == 0x00f6) 219 219 return 148; 220 220 221 221 if (ch == 0x00f7) 222 222 return 246; 223 223 224 224 if (ch == 0x00f9) 225 225 return 151; 226 226 227 227 if (ch == 0x00fa) 228 228 return 163; 229 229 230 230 if (ch == 0x00fb) 231 231 return 150; 232 232 233 233 if (ch == 0x00fc) 234 234 return 129; 235 235 236 236 if (ch == 0x00ff) 237 237 return 152; 238 238 239 239 if (ch == 0x0192) 240 240 return 159; 241 241 242 242 if (ch == 0x0393) 243 243 return 226; 244 244 245 245 if (ch == 0x0398) 246 246 return 233; 247 247 248 248 if (ch == 0x03a3) 249 249 return 228; 250 250 251 251 if (ch == 0x03a6) 252 252 return 232; 253 253 254 254 if (ch == 0x03a9) 255 255 return 234; 256 256 257 257 if (ch == 0x03b1) 258 258 return 224; 259 259 260 260 if (ch == 0x03b4) 261 261 return 235; 262 262 263 263 if (ch == 0x03b5) 264 264 return 238; 265 265 266 266 if (ch == 0x03c0) 267 267 return 227; 268 268 269 269 if (ch == 0x03c3) 270 270 return 229; 271 271 272 272 if (ch == 0x03c4) 273 273 return 231; 274 274 275 275 if (ch == 0x03c6) 276 276 return 237; 277 277 278 278 if (ch == 0x207f) 279 279 return 252; 280 280 281 281 if (ch == 0x20a7) 282 282 return 158; 283 283 284 284 if (ch == 0x2219) 285 285 return 249; 286 286 287 287 if (ch == 0x221a) 288 288 return 251; 289 289 290 290 if (ch == 0x221e) 291 291 return 236; 292 292 293 293 if (ch == 0x2229) 294 294 return 239; 295 295 296 296 if (ch == 0x2248) 297 297 return 247; 298 298 299 299 if (ch == 0x2261) 300 300 return 240; 301 301 302 302 if (ch == 0x2264) 303 303 return 243; 304 304 305 305 if (ch == 0x2265) 306 306 return 242; 307 307 308 308 if (ch == 0x2310) 309 309 return 169; 310 310 311 311 if ((ch >= 0x2320) && (ch <= 0x2321)) 312 312 return (ch - 8748); 313 313 314 314 if (ch == 0x2500) 315 315 return 196; 316 316 317 317 if (ch == 0x2502) 318 318 return 179; 319 319 320 320 if (ch == 0x250c) 321 321 return 218; 322 322 323 323 if (ch == 0x2510) 324 324 return 191; 325 325 326 326 if (ch == 0x2514) 327 327 return 192; 328 328 329 329 if (ch == 0x2518) 330 330 return 217; 331 331 332 332 if (ch == 0x251c) 333 333 return 195; 334 334 335 335 if (ch == 0x2524) 336 336 return 180; 337 337 338 338 if (ch == 0x252c) 339 339 return 194; 340 340 341 341 if (ch == 0x2534) 342 342 return 193; 343 343 344 344 if (ch == 0x253c) 345 345 return 197; 346 346 347 347 if (ch == 0x2550) 348 348 return 205; 349 349 350 350 if (ch == 0x2551) 351 351 return 186; 352 352 353 353 if ((ch >= 0x2552) && (ch <= 0x2553)) 354 354 return (ch - 9341); 355 355 356 356 if (ch == 0x2554) 357 357 return 201; 358 358 359 359 if (ch == 0x2555) 360 360 return 184; 361 361 362 362 if (ch == 0x2556) 363 363 return 183; 364 364 365 365 if (ch == 0x2557) 366 366 return 187; 367 367 368 368 if (ch == 0x2558) 369 369 return 212; 370 370 371 371 if (ch == 0x2559) 372 372 return 211; 373 373 374 374 if (ch == 0x255a) 375 375 return 200; 376 376 377 377 if (ch == 0x255b) 378 378 return 190; 379 379 380 380 if (ch == 0x255c) 381 381 return 189; 382 382 383 383 if (ch == 0x255d) 384 384 return 188; 385 385 386 386 if ((ch >= 0x255e) && (ch <= 0x255f)) 387 387 return (ch - 9368); 388 388 389 389 if (ch == 0x2560) 390 390 return 204; 391 391 392 392 if ((ch >= 0x2561) && (ch <= 0x2562)) 393 393 return (ch - 9388); 394 394 395 395 if (ch == 0x2563) 396 396 return 185; 397 397 398 398 if ((ch >= 0x2564) && (ch <= 0x2565)) 399 399 return (ch - 9363); 400 400 401 401 if (ch == 0x2566) 402 402 return 203; 403 403 404 404 if ((ch >= 0x2567) && (ch <= 0x2568)) 405 405 return (ch - 9368); 406 406 407 407 if (ch == 0x2569) 408 408 return 202; 409 409 410 410 if (ch == 0x256a) 411 411 return 216; 412 412 413 413 if (ch == 0x256b) 414 414 return 215; 415 415 416 416 if (ch == 0x256c) 417 417 return 206; 418 418 419 419 if (ch == 0x2580) 420 420 return 223; 421 421 422 422 if (ch == 0x2584) 423 423 return 220; 424 424 425 425 if (ch == 0x2588) 426 426 return 219; 427 427 428 428 if (ch == 0x258c) 429 429 return 221; 430 430 431 431 if (ch == 0x2590) 432 432 return 222; 433 433 434 434 if ((ch >= 0x2591) && (ch <= 0x2593)) 435 435 return (ch - 9441); 436 436 437 437 return 256; 438 438 } … … 445 445 if (instance->cursor < EGA_SCREEN) 446 446 return; 447 447 448 448 memmove((void *) instance->backbuf, 449 449 (void *) (instance->backbuf + EGA_COLS * 2), … … 451 451 memsetw(instance->backbuf + (EGA_SCREEN - EGA_COLS) * 2, 452 452 EGA_COLS, EMPTY_CHAR); 453 453 454 454 if ((!instance->parea.mapped) || (console_override)) { 455 455 memmove((void *) instance->addr, … … 459 459 EGA_COLS, EMPTY_CHAR); 460 460 } 461 461 462 462 instance->cursor = instance->cursor - EGA_COLS; 463 463 } … … 492 492 pio_write_8(instance->base + EGA_INDEX_REG, 0x0f); 493 493 uint8_t lo = pio_read_8(instance->base + EGA_DATA_REG); 494 494 495 495 instance->cursor = (hi << 8) | lo; 496 496 } else 497 497 instance->cursor = 0; 498 498 499 499 if (instance->cursor >= EGA_SCREEN) 500 500 instance->cursor = 0; 501 501 502 502 if ((instance->cursor % EGA_COLS) != 0) 503 503 instance->cursor = 504 504 (instance->cursor + EGA_COLS) - instance->cursor % EGA_COLS; 505 505 506 506 memsetw(instance->backbuf + instance->cursor * 2, 507 507 EGA_SCREEN - instance->cursor, EMPTY_CHAR); 508 508 509 509 if ((!instance->parea.mapped) || (console_override)) 510 510 memsetw(instance->addr + instance->cursor * 2, 511 511 EGA_SCREEN - instance->cursor, EMPTY_CHAR); 512 512 513 513 ega_check_cursor(instance); 514 514 ega_move_cursor(instance); … … 521 521 uint8_t glyph; 522 522 uint8_t style; 523 523 524 524 if ((index >> 8)) { 525 525 glyph = U_SPECIAL; … … 529 529 style = STYLE; 530 530 } 531 531 532 532 instance->backbuf[instance->cursor * 2] = glyph; 533 533 instance->backbuf[instance->cursor * 2 + 1] = style; 534 534 535 535 if ((!instance->parea.mapped) || (console_override)) { 536 536 instance->addr[instance->cursor * 2] = glyph; … … 542 542 { 543 543 ega_instance_t *instance = (ega_instance_t *) dev->data; 544 544 545 545 irq_spinlock_lock(&instance->lock, true); 546 546 547 547 switch (ch) { 548 548 case '\n': … … 565 565 ega_check_cursor(instance); 566 566 ega_move_cursor(instance); 567 567 568 568 irq_spinlock_unlock(&instance->lock, true); 569 569 } … … 572 572 { 573 573 ega_instance_t *instance = (ega_instance_t *) dev->data; 574 574 575 575 irq_spinlock_lock(&instance->lock, true); 576 576 577 577 memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE); 578 578 ega_move_cursor(instance); 579 579 ega_show_cursor(instance); 580 580 581 581 irq_spinlock_unlock(&instance->lock, true); 582 582 } … … 587 587 if (!egadev) 588 588 return NULL; 589 589 590 590 ega_instance_t *instance = malloc(sizeof(ega_instance_t), FRAME_ATOMIC); 591 591 if (!instance) { … … 593 593 return NULL; 594 594 } 595 595 596 596 outdev_initialize("egadev", egadev, &egadev_ops); 597 597 egadev->data = instance; 598 598 599 599 irq_spinlock_initialize(&instance->lock, "*ega.instance.lock"); 600 600 601 601 instance->base = base; 602 602 instance->addr = (uint8_t *) km_map(addr, EGA_VRAM_SIZE, … … 608 608 return NULL; 609 609 } 610 610 611 611 instance->backbuf = (uint8_t *) malloc(EGA_VRAM_SIZE, 0); 612 612 if (!instance->backbuf) { … … 616 616 return NULL; 617 617 } 618 618 619 619 link_initialize(&instance->parea.link); 620 620 instance->parea.pbase = addr; … … 623 623 instance->parea.mapped = false; 624 624 ddi_parea_register(&instance->parea); 625 625 626 626 /* Synchronize the back buffer and cursor position. */ 627 627 memcpy(instance->backbuf, instance->addr, EGA_VRAM_SIZE); 628 628 ega_sync_cursor(instance); 629 629 630 630 if (!fb_exported) { 631 631 /* … … 640 640 sysinfo_set_item_val("fb.blinking", NULL, true); 641 641 sysinfo_set_item_val("fb.address.physical", NULL, addr); 642 642 643 643 fb_exported = true; 644 644 } 645 645 646 646 return egadev; 647 647 } -
kernel/genarch/src/drivers/i8042/i8042.c
r3061bc1 ra35b458 59 59 i8042_instance_t *i8042_instance = irq->instance; 60 60 i8042_t *dev = i8042_instance->i8042; 61 61 62 62 if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) 63 63 return IRQ_ACCEPT; … … 70 70 i8042_instance_t *instance = irq->instance; 71 71 i8042_t *dev = instance->i8042; 72 72 73 73 if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) { 74 74 uint8_t data = pio_read_8(&dev->data); … … 83 83 if ((pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) == 0) 84 84 break; 85 85 86 86 (void) pio_read_8(&dev->data); 87 87 delay(50); /* 50 us think time */ … … 94 94 if ((pio_read_8(&dev->status) & i8042_WAIT_MASK) == 0) 95 95 break; 96 96 97 97 delay(50); /* 50 us think time */ 98 98 } 99 99 100 100 pio_write_8(&dev->status, cmd); 101 101 delay(10000); /* 10 ms think time */ … … 110 110 instance->i8042 = dev; 111 111 instance->kbrdin = NULL; 112 112 113 113 irq_initialize(&instance->irq); 114 114 instance->irq.inr = inr; … … 117 117 instance->irq.instance = instance; 118 118 } 119 119 120 120 return instance; 121 121 } … … 125 125 assert(instance); 126 126 assert(kbrdin); 127 127 128 128 i8042_clear_buffer(instance->i8042); 129 129 130 130 instance->kbrdin = kbrdin; 131 131 irq_register(&instance->irq); -
kernel/genarch/src/drivers/ns16550/ns16550.c
r3061bc1 ra35b458 71 71 { 72 72 ns16550_instance_t *instance = irq->instance; 73 73 74 74 while (ns16550_reg_read(instance, NS16550_REG_LSR) & LSR_DATA_READY) { 75 75 uint8_t data = ns16550_reg_read(instance, NS16550_REG_RBR); … … 95 95 { 96 96 ns16550_instance_t *instance = (ns16550_instance_t *) dev->data; 97 97 98 98 if ((!instance->parea.mapped) || (console_override)) { 99 99 if (ascii_check(ch)) … … 135 135 instance->input = NULL; 136 136 instance->output = NULL; 137 137 138 138 if (output) { 139 139 instance->output = malloc(sizeof(outdev_t), … … 143 143 return NULL; 144 144 } 145 145 146 146 outdev_initialize("ns16550", instance->output, 147 147 &ns16550_ops); … … 149 149 *output = instance->output; 150 150 } 151 151 152 152 irq_initialize(&instance->irq); 153 153 instance->irq.inr = inr; … … 157 157 instance->irq.cir = cir; 158 158 instance->irq.cir_arg = cir_arg; 159 159 160 160 instance->parea.pbase = (uintptr_t) dev; 161 161 instance->parea.frames = 1; … … 164 164 ddi_parea_register(&instance->parea); 165 165 } 166 166 167 167 return instance; 168 168 } … … 172 172 assert(instance); 173 173 assert(input); 174 174 175 175 instance->input = input; 176 176 irq_register(&instance->irq); 177 177 178 178 ns16550_clear_buffer(instance); 179 179 180 180 /* Enable interrupts */ 181 181 ns16550_reg_write(instance, NS16550_REG_IER, IER_ERBFI); -
kernel/genarch/src/drivers/pl050/pl050.c
r3061bc1 ra35b458 64 64 uint8_t status; 65 65 pl050_instance_t *instance = irq->instance; 66 66 67 67 while ((status = pio_read_8(pl050->status)) & PL050_STAT_RXFULL) { 68 68 data = pio_read_8(pl050->data); … … 98 98 { 99 99 uint8_t val; 100 100 101 101 instance->kbrdin = kbrdin; 102 102 irq_register(&instance->irq); … … 108 108 /* reset the data buffer */ 109 109 pio_read_8(pl050->data); 110 110 111 111 } 112 112 -
kernel/genarch/src/drivers/s3c24xx/uart.c
r3061bc1 ra35b458 65 65 s3c24xx_uart_t *uart = 66 66 (s3c24xx_uart_t *) dev->data; 67 67 68 68 if ((!uart->parea.mapped) || (console_override)) { 69 69 if (!ascii_check(ch)) { … … 134 134 pio_write_32(&uart->io->ucon, 135 135 pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL); 136 136 137 137 link_initialize(&uart->parea.link); 138 138 uart->parea.pbase = paddr; … … 141 141 uart->parea.mapped = false; 142 142 ddi_parea_register(&uart->parea); 143 143 144 144 if (!fb_exported) { 145 145 /* -
kernel/genarch/src/drivers/via-cuda/cuda.c
r3061bc1 ra35b458 113 113 instance->irq.preack = true; 114 114 } 115 115 116 116 return instance; 117 117 } … … 239 239 cuda_t *dev = instance->cuda; 240 240 uint8_t b; 241 241 242 242 b = pio_read_8(&dev->b); 243 243 pio_read_8(&dev->sr); 244 244 245 245 if ((b & TREQ) == 0) { 246 246 instance->xstate = cx_receive; … … 250 250 cuda_send_start(instance); 251 251 } 252 252 253 253 memcpy(buf, instance->rcv_buf, instance->bidx); 254 254 *len = instance->bidx; -
kernel/genarch/src/fb/bfb.c
r3061bc1 ra35b458 61 61 (bfb_bpp == 0) || (bfb_scanline == 0)) 62 62 return false; 63 63 64 64 fb_properties_t bfb_props = { 65 65 .addr = bfb_addr, … … 69 69 .scan = bfb_scanline 70 70 }; 71 71 72 72 switch (bfb_bpp) { 73 73 case 8: … … 92 92 return false; 93 93 } 94 94 95 95 outdev_t *fbdev = fb_init(&bfb_props); 96 96 if (!fbdev) 97 97 return false; 98 98 99 99 stdout_wire(fbdev); 100 100 return true; -
kernel/genarch/src/fb/fb.c
r3061bc1 ra35b458 84 84 typedef struct { 85 85 SPINLOCK_DECLARE(lock); 86 86 87 87 parea_t parea; 88 88 89 89 uint8_t *addr; 90 90 uint16_t *backbuf; 91 91 uint8_t *glyphs; 92 92 uint8_t *bgscan; 93 93 94 94 rgb_conv_t rgb_conv; 95 95 96 96 unsigned int xres; 97 97 unsigned int yres; 98 98 99 99 /** Number of rows that fit on framebuffer */ 100 100 unsigned int rowtrim; 101 101 102 102 unsigned int scanline; 103 103 unsigned int glyphscanline; 104 104 105 105 unsigned int pixelbytes; 106 106 unsigned int glyphbytes; 107 107 unsigned int bgscanbytes; 108 108 109 109 /** Number of columns in the backbuffer */ 110 110 unsigned int cols; 111 111 /** Number of rows in the backbuffer */ 112 112 unsigned int rows; 113 113 114 114 /** Starting row in the cyclic backbuffer */ 115 115 unsigned int start_row; 116 116 117 117 /** Top-most visible row (relative to start_row) */ 118 118 unsigned int offset_row; 119 119 120 120 /** Current backbuffer position */ 121 121 unsigned int position; … … 236 236 if (!overlay) 237 237 instance->backbuf[BB_POS(instance, col, row)] = glyph; 238 238 239 239 /* Do not output if the framebuffer is used by user space */ 240 240 if ((instance->parea.mapped) && (!console_override)) 241 241 return; 242 242 243 243 /* Check whether the glyph should be visible */ 244 244 if (row < instance->offset_row) 245 245 return; 246 246 247 247 unsigned int rel_row = row - instance->offset_row; 248 248 if (rel_row >= instance->rowtrim) 249 249 return; 250 250 251 251 unsigned int x = COL2X(col); 252 252 unsigned int y = ROW2Y(rel_row); 253 253 254 254 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) 255 255 memcpy(&instance->addr[FB_POS(instance, x, y + yd)], … … 267 267 unsigned int y = ROW2Y(rel_row); 268 268 unsigned int row = rel_row + instance->offset_row; 269 269 270 270 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) { 271 271 unsigned int x; 272 272 unsigned int col; 273 273 274 274 for (col = 0, x = 0; col < instance->cols; 275 275 col++, x += FONT_WIDTH) { 276 276 uint16_t glyph; 277 277 278 278 if (row < instance->rows - 1) { 279 279 if (instance->backbuf[BB_POS(instance, col, row)] == 280 280 instance->backbuf[BB_POS(instance, col, row + 1)]) 281 281 continue; 282 282 283 283 glyph = instance->backbuf[BB_POS(instance, col, row + 1)]; 284 284 } else 285 285 glyph = 0; 286 286 287 287 memcpy(&instance->addr[FB_POS(instance, x, y + yd)], 288 288 &instance->glyphs[GLYPH_POS(instance, glyph, yd)], … … 292 292 } 293 293 } 294 294 295 295 /* 296 296 * Implement backbuffer scrolling by wrapping around 297 297 * the cyclic buffer. 298 298 */ 299 299 300 300 instance->start_row++; 301 301 if (instance->start_row == instance->rows) 302 302 instance->start_row = 0; 303 303 304 304 memsetw(&instance->backbuf[BB_POS(instance, 0, instance->rows - 1)], 305 305 instance->cols, 0); … … 310 310 unsigned int col = instance->position % instance->cols; 311 311 unsigned int row = instance->position / instance->cols; 312 312 313 313 glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true); 314 314 } … … 318 318 unsigned int col = instance->position % instance->cols; 319 319 unsigned int row = instance->position / instance->cols; 320 320 321 321 glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)], 322 322 col, row, true); … … 333 333 /* Prerender glyphs */ 334 334 uint16_t glyph; 335 335 336 336 for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { 337 337 uint32_t fg_color; 338 338 339 339 if (glyph == FONT_GLYPHS - 1) 340 340 fg_color = INV_COLOR; 341 341 else 342 342 fg_color = FG_COLOR; 343 343 344 344 unsigned int y; 345 345 346 346 for (y = 0; y < FONT_SCANLINES; y++) { 347 347 unsigned int x; 348 348 349 349 for (x = 0; x < FONT_WIDTH; x++) { 350 350 void *dst = … … 357 357 } 358 358 } 359 359 360 360 /* Prerender background scanline */ 361 361 unsigned int x; 362 362 363 363 for (x = 0; x < instance->xres; x++) 364 364 instance->rgb_conv(&instance->bgscan[x * instance->pixelbytes], BG_COLOR); … … 370 370 unsigned int y = ROW2Y(rel_row); 371 371 unsigned int row = rel_row + instance->offset_row; 372 372 373 373 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) { 374 374 unsigned int x; 375 375 unsigned int col; 376 376 377 377 for (col = 0, x = 0; col < instance->cols; 378 378 col++, x += FONT_WIDTH) { … … 385 385 } 386 386 } 387 387 388 388 if (COL2X(instance->cols) < instance->xres) { 389 389 unsigned int y; 390 390 unsigned int size = 391 391 (instance->xres - COL2X(instance->cols)) * instance->pixelbytes; 392 392 393 393 for (y = 0; y < instance->yres; y++) 394 394 memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)], 395 395 instance->bgscan, size); 396 396 } 397 397 398 398 if (ROW2Y(instance->rowtrim) < instance->yres) { 399 399 unsigned int y; 400 400 401 401 for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++) 402 402 memcpy(&instance->addr[FB_POS(instance, 0, y)], … … 414 414 fb_instance_t *instance = (fb_instance_t *) dev->data; 415 415 spinlock_lock(&instance->lock); 416 416 417 417 switch (ch) { 418 418 case '\n': … … 446 446 instance->position++; 447 447 } 448 448 449 449 if (instance->position >= instance->cols * instance->rows) { 450 450 instance->position -= instance->cols; 451 451 screen_scroll(instance); 452 452 } 453 453 454 454 cursor_put(instance); 455 455 456 456 spinlock_unlock(&instance->lock); 457 457 } … … 464 464 fb_instance_t *instance = (fb_instance_t *) dev->data; 465 465 spinlock_lock(&instance->lock); 466 466 467 467 if (instance->offset_row >= instance->rowtrim / 2) 468 468 instance->offset_row -= instance->rowtrim / 2; 469 469 else 470 470 instance->offset_row = 0; 471 471 472 472 fb_redraw_internal(instance); 473 473 cursor_put(instance); 474 474 475 475 spinlock_unlock(&instance->lock); 476 476 } … … 483 483 fb_instance_t *instance = (fb_instance_t *) dev->data; 484 484 spinlock_lock(&instance->lock); 485 485 486 486 if (instance->offset_row + instance->rowtrim / 2 <= 487 487 instance->rows - instance->rowtrim) … … 489 489 else 490 490 instance->offset_row = instance->rows - instance->rowtrim; 491 491 492 492 fb_redraw_internal(instance); 493 493 cursor_put(instance); 494 494 495 495 spinlock_unlock(&instance->lock); 496 496 } … … 502 502 { 503 503 fb_instance_t *instance = (fb_instance_t *) dev->data; 504 504 505 505 spinlock_lock(&instance->lock); 506 506 fb_redraw_internal(instance); … … 517 517 assert(props->y > 0); 518 518 assert(props->scan > 0); 519 519 520 520 rgb_conv_t rgb_conv; 521 521 unsigned int pixelbytes; 522 522 523 523 switch (props->visual) { 524 524 case VISUAL_INDIRECT_8: … … 570 570 return NULL; 571 571 } 572 572 573 573 outdev_t *fbdev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 574 574 if (!fbdev) 575 575 return NULL; 576 576 577 577 fb_instance_t *instance = malloc(sizeof(fb_instance_t), FRAME_ATOMIC); 578 578 if (!instance) { … … 580 580 return NULL; 581 581 } 582 582 583 583 outdev_initialize("fbdev", fbdev, &fbdev_ops); 584 584 fbdev->data = instance; 585 585 586 586 spinlock_initialize(&instance->lock, "*fb.instance.lock"); 587 587 588 588 instance->rgb_conv = rgb_conv; 589 589 instance->pixelbytes = pixelbytes; … … 591 591 instance->yres = props->y; 592 592 instance->scanline = props->scan; 593 593 594 594 instance->rowtrim = Y2ROW(instance->yres); 595 595 596 596 instance->cols = X2COL(instance->xres); 597 597 instance->rows = FB_PAGES * instance->rowtrim; 598 598 599 599 instance->start_row = instance->rows - instance->rowtrim; 600 600 instance->offset_row = instance->start_row; 601 601 instance->position = instance->start_row * instance->cols; 602 602 603 603 instance->glyphscanline = FONT_WIDTH * instance->pixelbytes; 604 604 instance->glyphbytes = ROW2Y(instance->glyphscanline); 605 605 instance->bgscanbytes = instance->xres * instance->pixelbytes; 606 606 607 607 size_t fbsize = instance->scanline * instance->yres; 608 608 size_t bbsize = instance->cols * instance->rows * sizeof(uint16_t); 609 609 size_t glyphsize = FONT_GLYPHS * instance->glyphbytes; 610 610 611 611 instance->addr = (uint8_t *) km_map((uintptr_t) props->addr, fbsize, 612 612 PAGE_WRITE | PAGE_NOT_CACHEABLE); … … 617 617 return NULL; 618 618 } 619 619 620 620 instance->backbuf = (uint16_t *) malloc(bbsize, 0); 621 621 if (!instance->backbuf) { … … 625 625 return NULL; 626 626 } 627 627 628 628 instance->glyphs = (uint8_t *) malloc(glyphsize, 0); 629 629 if (!instance->glyphs) { … … 634 634 return NULL; 635 635 } 636 636 637 637 instance->bgscan = malloc(instance->bgscanbytes, 0); 638 638 if (!instance->bgscan) { … … 644 644 return NULL; 645 645 } 646 646 647 647 memsetw(instance->backbuf, instance->cols * instance->rows, 0); 648 648 glyphs_render(instance); 649 649 650 650 link_initialize(&instance->parea.link); 651 651 instance->parea.pbase = props->addr; … … 654 654 instance->parea.mapped = false; 655 655 ddi_parea_register(&instance->parea); 656 656 657 657 if (!fb_exported) { 658 658 /* … … 668 668 sysinfo_set_item_val("fb.visual", NULL, props->visual); 669 669 sysinfo_set_item_val("fb.address.physical", NULL, props->addr); 670 670 671 671 fb_exported = true; 672 672 } 673 673 674 674 fb_redraw(fbdev); 675 675 return fbdev; -
kernel/genarch/src/fb/font-8x16.c
r3061bc1 ra35b458 47 47 if (ch == 0x0000) 48 48 return 0; 49 49 50 50 if ((ch >= 0x0020) && (ch <= 0x007f)) 51 51 return (ch - 32); 52 52 53 53 if ((ch >= 0x00a0) && (ch <= 0x021f)) 54 54 return (ch - 64); 55 55 56 56 if ((ch >= 0x0222) && (ch <= 0x0233)) 57 57 return (ch - 66); 58 58 59 59 if ((ch >= 0x0250) && (ch <= 0x02ad)) 60 60 return (ch - 94); 61 61 62 62 if ((ch >= 0x02b0) && (ch <= 0x02cf)) 63 63 return (ch - 96); 64 64 65 65 if ((ch >= 0x02d8) && (ch <= 0x02dd)) 66 66 return (ch - 104); 67 67 68 68 if (ch == 0x02ee) 69 69 return 630; 70 70 71 71 if ((ch >= 0x0300) && (ch <= 0x0301)) 72 72 return (ch - 137); 73 73 74 74 if (ch == 0x0303) 75 75 return 633; 76 76 77 77 if (ch == 0x0309) 78 78 return 634; 79 79 80 80 if ((ch >= 0x0312) && (ch <= 0x0314)) 81 81 return (ch - 151); 82 82 83 83 if (ch == 0x0323) 84 84 return 638; 85 85 86 86 if ((ch >= 0x0340) && (ch <= 0x0341)) 87 87 return (ch - 193); 88 88 89 89 if ((ch >= 0x0374) && (ch <= 0x0375)) 90 90 return (ch - 243); 91 91 92 92 if (ch == 0x037a) 93 93 return 643; 94 94 95 95 if (ch == 0x037e) 96 96 return 644; 97 97 98 98 if ((ch >= 0x0384) && (ch <= 0x038a)) 99 99 return (ch - 255); 100 100 101 101 if (ch == 0x038c) 102 102 return 652; 103 103 104 104 if ((ch >= 0x038e) && (ch <= 0x03a1)) 105 105 return (ch - 257); 106 106 107 107 if ((ch >= 0x03a3) && (ch <= 0x03ce)) 108 108 return (ch - 258); 109 109 110 110 if ((ch >= 0x03d0) && (ch <= 0x03d7)) 111 111 return (ch - 259); 112 112 113 113 if ((ch >= 0x03da) && (ch <= 0x03f3)) 114 114 return (ch - 261); 115 115 116 116 if ((ch >= 0x0400) && (ch <= 0x0486)) 117 117 return (ch - 273); 118 118 119 119 if ((ch >= 0x0488) && (ch <= 0x04ce)) 120 120 return (ch - 274); 121 121 122 122 if ((ch >= 0x04d0) && (ch <= 0x04f5)) 123 123 return (ch - 275); 124 124 125 125 if ((ch >= 0x04f8) && (ch <= 0x04f9)) 126 126 return (ch - 277); 127 127 128 128 if ((ch >= 0x0500) && (ch <= 0x050f)) 129 129 return (ch - 283); 130 130 131 131 if ((ch >= 0x0530) && (ch <= 0x0556)) 132 132 return (ch - 315); 133 133 134 134 if ((ch >= 0x0559) && (ch <= 0x055f)) 135 135 return (ch - 317); 136 136 137 137 if ((ch >= 0x0561) && (ch <= 0x0587)) 138 138 return (ch - 318); 139 139 140 140 if ((ch >= 0x0589) && (ch <= 0x058a)) 141 141 return (ch - 319); 142 142 143 143 if ((ch >= 0x0591) && (ch <= 0x05a1)) 144 144 return (ch - 325); 145 145 146 146 if ((ch >= 0x05a3) && (ch <= 0x05b9)) 147 147 return (ch - 326); 148 148 149 149 if ((ch >= 0x05bb) && (ch <= 0x05c4)) 150 150 return (ch - 327); 151 151 152 152 if ((ch >= 0x05d0) && (ch <= 0x05ea)) 153 153 return (ch - 338); 154 154 155 155 if ((ch >= 0x05f0) && (ch <= 0x05f4)) 156 156 return (ch - 343); 157 157 158 158 if (ch == 0x060c) 159 159 return 1182; 160 160 161 161 if (ch == 0x061b) 162 162 return 1183; 163 163 164 164 if (ch == 0x061f) 165 165 return 1184; 166 166 167 167 if ((ch >= 0x0621) && (ch <= 0x063a)) 168 168 return (ch - 384); 169 169 170 170 if ((ch >= 0x0640) && (ch <= 0x0655)) 171 171 return (ch - 389); 172 172 173 173 if ((ch >= 0x0660) && (ch <= 0x066d)) 174 174 return (ch - 399); 175 175 176 176 if ((ch >= 0x0670) && (ch <= 0x06ed)) 177 177 return (ch - 401); 178 178 179 179 if ((ch >= 0x06f0) && (ch <= 0x06fe)) 180 180 return (ch - 403); 181 181 182 182 if (ch == 0x10d3) 183 183 return 1388; 184 184 185 185 if (ch == 0x10d7) 186 186 return 1389; 187 187 188 188 if (ch == 0x10da) 189 189 return 1390; 190 190 191 191 if (ch == 0x10dd) 192 192 return 1391; 193 193 194 194 if (ch == 0x10e6) 195 195 return 1392; 196 196 197 197 if ((ch >= 0x1e00) && (ch <= 0x1e9b)) 198 198 return (ch - 6287); 199 199 200 200 if ((ch >= 0x1ea0) && (ch <= 0x1ef9)) 201 201 return (ch - 6291); 202 202 203 203 if ((ch >= 0x1f00) && (ch <= 0x1f07)) 204 204 return (ch - 6297); 205 205 206 206 if ((ch >= 0x2000) && (ch <= 0x2027)) 207 207 return (ch - 6545); 208 208 209 209 if ((ch >= 0x2030) && (ch <= 0x2046)) 210 210 return (ch - 6553); 211 211 212 212 if ((ch >= 0x2048) && (ch <= 0x204d)) 213 213 return (ch - 6554); 214 214 215 215 if (ch == 0x2070) 216 216 return 1716; 217 217 218 218 if ((ch >= 0x2074) && (ch <= 0x208f)) 219 219 return (ch - 6591); 220 220 221 221 if ((ch >= 0x20a0) && (ch <= 0x20af)) 222 222 return (ch - 6607); 223 223 224 224 if ((ch >= 0x2100) && (ch <= 0x213a)) 225 225 return (ch - 6687); 226 226 227 227 if ((ch >= 0x2153) && (ch <= 0x2183)) 228 228 return (ch - 6711); 229 229 230 230 if ((ch >= 0x2190) && (ch <= 0x21f3)) 231 231 return (ch - 6723); 232 232 233 233 if ((ch >= 0x2200) && (ch <= 0x22f1)) 234 234 return (ch - 6735); 235 235 236 236 if (ch == 0x2300) 237 237 return 2211; 238 238 239 239 if (ch == 0x2302) 240 240 return 2212; 241 241 242 242 if ((ch >= 0x2308) && (ch <= 0x230b)) 243 243 return (ch - 6755); 244 244 245 245 if (ch == 0x2310) 246 246 return 2217; 247 247 248 248 if (ch == 0x2318) 249 249 return 2218; 250 250 251 251 if ((ch >= 0x231a) && (ch <= 0x231b)) 252 252 return (ch - 6767); 253 253 254 254 if ((ch >= 0x2320) && (ch <= 0x2321)) 255 255 return (ch - 6771); 256 256 257 257 if ((ch >= 0x2329) && (ch <= 0x232a)) 258 258 return (ch - 6778); 259 259 260 260 if ((ch >= 0x239b) && (ch <= 0x23bd)) 261 261 return (ch - 6890); 262 262 263 263 if (ch == 0x23ce) 264 264 return 2260; 265 265 266 266 if ((ch >= 0x2409) && (ch <= 0x240d)) 267 267 return (ch - 6964); 268 268 269 269 if ((ch >= 0x2423) && (ch <= 0x2424)) 270 270 return (ch - 6985); 271 271 272 272 if (ch == 0x2426) 273 273 return 2268; 274 274 275 275 if ((ch >= 0x2500) && (ch <= 0x2595)) 276 276 return (ch - 7203); 277 277 278 278 if ((ch >= 0x25a0) && (ch <= 0x25f7)) 279 279 return (ch - 7213); 280 280 281 281 if ((ch >= 0x2600) && (ch <= 0x2602)) 282 282 return (ch - 7221); 283 283 284 284 if ((ch >= 0x2605) && (ch <= 0x260d)) 285 285 return (ch - 7223); 286 286 287 287 if ((ch >= 0x2610) && (ch <= 0x2613)) 288 288 return (ch - 7225); 289 289 290 290 if (ch == 0x2620) 291 291 return 2523; 292 292 293 293 if (ch == 0x2622) 294 294 return 2524; 295 295 296 296 if (ch == 0x2626) 297 297 return 2525; 298 298 299 299 if ((ch >= 0x2628) && (ch <= 0x262b)) 300 300 return (ch - 7242); 301 301 302 302 if ((ch >= 0x262e) && (ch <= 0x2637)) 303 303 return (ch - 7244); 304 304 305 305 if ((ch >= 0x2639) && (ch <= 0x2653)) 306 306 return (ch - 7245); 307 307 308 308 if ((ch >= 0x2660) && (ch <= 0x2667)) 309 309 return (ch - 7257); 310 310 311 311 if ((ch >= 0x2669) && (ch <= 0x266f)) 312 312 return (ch - 7258); 313 313 314 314 if ((ch >= 0xfb00) && (ch <= 0xfb05)) 315 315 return (ch - 61674); 316 316 317 317 if ((ch >= 0xfb50) && (ch <= 0xfbb1)) 318 318 return (ch - 61748); 319 319 320 320 if ((ch >= 0xfbd3) && (ch <= 0xfbe9)) 321 321 return (ch - 61781); 322 322 323 323 if ((ch >= 0xfbfc) && (ch <= 0xfbff)) 324 324 return (ch - 61799); 325 325 326 326 if ((ch >= 0xfc5b) && (ch <= 0xfc63)) 327 327 return (ch - 61890); 328 328 329 329 if (ch == 0xfc90) 330 330 return 2722; 331 331 332 332 if ((ch >= 0xfcf2) && (ch <= 0xfcf4)) 333 333 return (ch - 62031); 334 334 335 335 if ((ch >= 0xfd3c) && (ch <= 0xfd3f)) 336 336 return (ch - 62102); 337 337 338 338 if (ch == 0xfdf2) 339 339 return 2730; 340 340 341 341 if ((ch >= 0xfe50) && (ch <= 0xfe52)) 342 342 return (ch - 62373); 343 343 344 344 if ((ch >= 0xfe54) && (ch <= 0xfe66)) 345 345 return (ch - 62374); 346 346 347 347 if ((ch >= 0xfe68) && (ch <= 0xfe6b)) 348 348 return (ch - 62375); 349 349 350 350 if ((ch >= 0xfe70) && (ch <= 0xfe72)) 351 351 return (ch - 62379); 352 352 353 353 if (ch == 0xfe74) 354 354 return 2760; 355 355 356 356 if ((ch >= 0xfe76) && (ch <= 0xfefc)) 357 357 return (ch - 62381); 358 358 359 359 if (ch == 0xfeff) 360 360 return 2896; 361 361 362 362 return 2898; 363 363 } … … 3262 3262 {0xf1, 0x35, 0x55, 0x8a, 0xe0, 0x06, 0x95, 0xd6, 0xb5, 0x97, 0x00, 0xee, 0x8a, 0xee, 0x28, 0xe8}, 3263 3263 {0x00, 0x38, 0x7c, 0x7c, 0xc6, 0x92, 0xf2, 0xe6, 0xfe, 0xe6, 0x7c, 0x7c, 0x38, 0x00, 0x00, 0x00}, 3264 3264 3265 3265 /* Special glyph for unknown character */ 3266 3266 {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00} -
kernel/genarch/src/kbrd/kbrd.c
r3061bc1 ra35b458 78 78 { 79 79 spinlock_lock(&instance->keylock); 80 80 81 81 switch (sc) { 82 82 case SC_LSHIFT: … … 94 94 break; 95 95 } 96 96 97 97 spinlock_unlock(&instance->keylock); 98 98 } … … 108 108 bool capslock; 109 109 wchar_t ch; 110 110 111 111 spinlock_lock(&instance->keylock); 112 112 113 113 switch (sc) { 114 114 case SC_LSHIFT: … … 126 126 capslock = (instance->keyflags & PRESSED_CAPSLOCK) || 127 127 (instance->lockflags & LOCKED_CAPSLOCK); 128 128 129 129 if ((letter) && (capslock)) 130 130 shift = !shift; 131 131 132 132 if (shift) 133 133 ch = sc_secondary_map[sc]; 134 134 else 135 135 ch = sc_primary_map[sc]; 136 136 137 137 switch (ch) { 138 138 case U_PAGE_UP: … … 145 145 indev_push_character(instance->sink, ch); 146 146 } 147 148 break; 149 } 150 147 148 break; 149 } 150 151 151 spinlock_unlock(&instance->keylock); 152 152 } … … 155 155 { 156 156 kbrd_instance_t *instance = (kbrd_instance_t *) arg; 157 157 158 158 while (true) { 159 159 wchar_t sc = indev_pop_character(&instance->raw); 160 160 161 161 if (sc == IGNORE_CODE) 162 162 continue; 163 163 164 164 if (sc & KEY_RELEASE) 165 165 key_released(instance, (sc ^ KEY_RELEASE) & 0x7f); … … 176 176 instance->thread = thread_create(kkbrd, (void *) instance, 177 177 TASK, THREAD_FLAG_NONE, "kkbrd"); 178 178 179 179 if (!instance->thread) { 180 180 free(instance); 181 181 return NULL; 182 182 } 183 183 184 184 instance->sink = NULL; 185 185 indev_initialize("kbrd", &instance->raw, &kbrd_raw_ops); 186 186 187 187 spinlock_initialize(&instance->keylock, "kbrd.instance.keylock"); 188 188 instance->keyflags = 0; 189 189 instance->lockflags = 0; 190 190 } 191 191 192 192 return instance; 193 193 } … … 197 197 assert(instance); 198 198 assert(sink); 199 199 200 200 instance->sink = sink; 201 201 thread_ready(instance->thread); 202 202 203 203 return &instance->raw; 204 204 } -
kernel/genarch/src/kbrd/kbrd_at.c
r3061bc1 ra35b458 71 71 { 72 72 spinlock_lock(&instance->keylock); 73 73 74 74 switch (sc) { 75 75 case SC_LSHIFT: … … 87 87 break; 88 88 } 89 89 90 90 spinlock_unlock(&instance->keylock); 91 91 } … … 100 100 bool shift; 101 101 bool capslock; 102 102 103 103 spinlock_lock(&instance->keylock); 104 104 105 105 switch (sc) { 106 106 case SC_LSHIFT: … … 118 118 capslock = (instance->keyflags & PRESSED_CAPSLOCK) || 119 119 (instance->lockflags & LOCKED_CAPSLOCK); 120 120 121 121 if ((letter) && (capslock)) 122 122 shift = !shift; 123 123 124 124 if (shift) 125 125 indev_push_character(instance->sink, sc_secondary_map[sc]); … … 128 128 break; 129 129 } 130 130 131 131 spinlock_unlock(&instance->keylock); 132 132 } … … 137 137 static int is_locked = 0; 138 138 kbrd_instance_t *instance = (kbrd_instance_t *) arg; 139 139 140 140 while (true) { 141 141 wchar_t sc = indev_pop_character(&instance->raw); … … 162 162 } 163 163 } 164 164 165 165 } 166 166 } … … 174 174 instance->thread = thread_create(kkbrd, (void *) instance, TASK, 0, 175 175 "kkbrd"); 176 176 177 177 if (!instance->thread) { 178 178 free(instance); 179 179 return NULL; 180 180 } 181 181 182 182 instance->sink = NULL; 183 183 indev_initialize("kbrd", &instance->raw, &kbrd_raw_ops); 184 184 185 185 spinlock_initialize(&instance->keylock, "kbrd_at.instance.keylock"); 186 186 instance->keyflags = 0; 187 187 instance->lockflags = 0; 188 188 } 189 189 190 190 return instance; 191 191 } … … 195 195 assert(instance); 196 196 assert(sink); 197 197 198 198 instance->sink = sink; 199 199 thread_ready(instance->thread); 200 200 201 201 return &instance->raw; 202 202 } -
kernel/genarch/src/kbrd/scanc_pc.c
r3061bc1 ra35b458 158 158 U_SPECIAL, /* 0x45 - NumLock */ 159 159 U_SPECIAL, /* 0x46 - ScrollLock */ 160 160 161 161 U_HOME_ARROW, /* 0x47 - Home */ 162 162 U_UP_ARROW, /* 0x48 - Up Arrow */ -
kernel/genarch/src/mm/as_ht.c
r3061bc1 ra35b458 79 79 NULL, NULL, SLAB_CACHE_MAGDEFERRED); 80 80 } 81 81 82 82 return NULL; 83 83 } -
kernel/genarch/src/mm/as_pt.c
r3061bc1 ra35b458 75 75 pte_t *dst_ptl0 = (pte_t *) 76 76 PA2KA(frame_alloc(PTL0_FRAMES, FRAME_LOWMEM, PTL0_SIZE - 1)); 77 77 78 78 if (flags & FLAG_AS_KERNEL) 79 79 memsetb(dst_ptl0, PTL0_SIZE, 0); … … 82 82 * Copy the kernel address space portion to new PTL0. 83 83 */ 84 84 85 85 mutex_lock(&AS_KERNEL->lock); 86 86 87 87 pte_t *src_ptl0 = 88 88 (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table); 89 89 90 90 uintptr_t src = (uintptr_t) 91 91 &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)]; 92 92 uintptr_t dst = (uintptr_t) 93 93 &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)]; 94 94 95 95 memsetb(dst_ptl0, PTL0_SIZE, 0); 96 96 memcpy((void *) dst, (void *) src, 97 97 PTL0_SIZE - (src - (uintptr_t) src_ptl0)); 98 98 99 99 mutex_unlock(&AS_KERNEL->lock); 100 100 } 101 101 102 102 return (pte_t *) KA2PA((uintptr_t) dst_ptl0); 103 103 } -
kernel/genarch/src/mm/asid.c
r3061bc1 ra35b458 84 84 * Check if there is an unallocated ASID. 85 85 */ 86 86 87 87 if (asids_allocated == ASIDS_ALLOCABLE) { 88 88 … … 91 91 * Resort to stealing. 92 92 */ 93 93 94 94 /* 95 95 * Remove the first item on the list. … … 100 100 assert(tmp != NULL); 101 101 list_remove(tmp); 102 102 103 103 as = list_get_instance(tmp, as_t, inactive_as_with_asid_link); 104 104 … … 115 115 */ 116 116 as->asid = ASID_INVALID; 117 117 118 118 /* 119 119 * If the architecture uses some software cache … … 122 122 */ 123 123 as_invalidate_translation_cache(as, 0, (size_t) -1); 124 124 125 125 /* 126 126 * Get the system rid of the stolen ASID. … … 146 146 tlb_shootdown_finalize(ipl); 147 147 } 148 148 149 149 return asid; 150 150 } -
kernel/genarch/src/mm/asid_fifo.c
r3061bc1 ra35b458 30 30 * @{ 31 31 */ 32 32 33 33 /** 34 34 * @file … … 66 66 fifo_create(free_asids); 67 67 #endif 68 68 69 69 for (i = 0; i < ASIDS_ALLOCABLE; i++) { 70 70 fifo_push(free_asids, ASID_START + i); -
kernel/genarch/src/mm/page_ht.c
r3061bc1 ra35b458 135 135 { 136 136 assert(item); 137 137 138 138 pte_t *pte = hash_table_get_inst(item, pte_t, link); 139 139 slab_free(pte_cache, pte); … … 162 162 163 163 irq_spinlock_lock(&page_ht_lock, true); 164 164 165 165 if (!hash_table_find(&page_ht, key)) { 166 166 pte_t *pte = slab_alloc(pte_cache, FRAME_LOWMEM | FRAME_ATOMIC); 167 167 assert(pte != NULL); 168 168 169 169 pte->g = (flags & PAGE_GLOBAL) != 0; 170 170 pte->x = (flags & PAGE_EXEC) != 0; … … 175 175 pte->a = false; 176 176 pte->d = false; 177 177 178 178 pte->as = as; 179 179 pte->page = ALIGN_DOWN(page, PAGE_SIZE); … … 185 185 */ 186 186 write_barrier(); 187 187 188 188 hash_table_insert(&page_ht, &pte->link); 189 189 } … … 210 210 211 211 assert(page_table_locked(as)); 212 212 213 213 irq_spinlock_lock(&page_ht_lock, true); 214 214 … … 235 235 if (cur) 236 236 return hash_table_get_inst(cur, pte_t, link); 237 237 238 238 return NULL; 239 239 } … … 257 257 258 258 irq_spinlock_unlock(&page_ht_lock, true); 259 259 260 260 return t != NULL; 261 261 } … … 275 275 if (!t) 276 276 panic("Updating non-existent PTE"); 277 277 278 278 assert(pte->as == t->as); 279 279 assert(pte->page == t->page); -
kernel/genarch/src/mm/page_pt.c
r3061bc1 ra35b458 83 83 84 84 assert(page_table_locked(as)); 85 85 86 86 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 87 87 pte_t *newpt = (pte_t *) … … 100 100 SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page)); 101 101 } 102 102 103 103 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 104 104 105 105 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 106 106 pte_t *newpt = (pte_t *) … … 117 117 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 118 118 } 119 119 120 120 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 121 121 122 122 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 123 123 pte_t *newpt = (pte_t *) … … 134 134 SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page)); 135 135 } 136 136 137 137 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 138 138 139 139 SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); 140 140 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT); … … 165 165 * First, remove the mapping, if it exists. 166 166 */ 167 167 168 168 pte_t *ptl0 = (pte_t *) PA2KA((uintptr_t) as->genarch.page_table); 169 169 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) 170 170 return; 171 171 172 172 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 173 173 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) 174 174 return; 175 175 176 176 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 177 177 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) 178 178 return; 179 179 180 180 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 181 181 182 182 /* 183 183 * Destroy the mapping. … … 189 189 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), PAGE_NOT_PRESENT); 190 190 memsetb(&ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); 191 191 192 192 /* 193 193 * Second, free all empty tables along the way from PTL3 down to PTL0 194 194 * except those needed for sharing the kernel non-identity mappings. 195 195 */ 196 196 197 197 /* Check PTL3 */ 198 198 bool empty = true; 199 199 200 200 unsigned int i; 201 201 for (i = 0; i < PTL3_ENTRIES; i++) { … … 205 205 } 206 206 } 207 207 208 208 if (empty) { 209 209 /* … … 232 232 return; 233 233 } 234 234 235 235 /* Check PTL2, empty is still true */ 236 236 #if (PTL2_ENTRIES != 0) … … 241 241 } 242 242 } 243 243 244 244 if (empty) { 245 245 /* … … 267 267 } 268 268 #endif /* PTL2_ENTRIES != 0 */ 269 269 270 270 /* check PTL1, empty is still true */ 271 271 #if (PTL1_ENTRIES != 0) … … 276 276 } 277 277 } 278 278 279 279 if (empty) { 280 280 /* … … 301 301 302 302 read_barrier(); 303 303 304 304 pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 305 305 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) … … 312 312 read_barrier(); 313 313 #endif 314 314 315 315 pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 316 316 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) … … 323 323 read_barrier(); 324 324 #endif 325 325 326 326 pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 327 327 328 328 return &ptl3[PTL3_INDEX(page)]; 329 329 } … … 400 400 { 401 401 assert(size > 0); 402 402 403 403 uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table); 404 404 uintptr_t ptl0_step = ptl0_step_get(); 405 405 size_t frames; 406 406 407 407 #if (PTL1_ENTRIES != 0) 408 408 frames = PTL1_FRAMES; … … 412 412 frames = PTL3_FRAMES; 413 413 #endif 414 414 415 415 for (uintptr_t addr = ALIGN_DOWN(base, ptl0_step); 416 416 addr - 1 < base + size - 1; -
kernel/genarch/src/multiboot/multiboot.c
r3061bc1 ra35b458 52 52 if (end == NULL) 53 53 end = cmd_line + str_size(cmd_line); 54 54 55 55 /* 56 56 * Find last occurence of '/' before 'end'. If found, place start at … … 59 59 const char *cp = end; 60 60 const char *start = buf; 61 61 62 62 while (cp != start) { 63 63 if (*cp == '/') { … … 67 67 cp--; 68 68 } 69 69 70 70 /* Copy the command. */ 71 71 str_ncpy(buf, size, start, (size_t) (end - start)); … … 106 106 if (init.cnt >= CONFIG_INIT_TASKS) 107 107 break; 108 108 109 109 init.tasks[init.cnt].paddr = mods[i].start; 110 110 init.tasks[init.cnt].size = mods[i].end - mods[i].start; 111 111 112 112 /* Copy command line, if available. */ 113 113 if (mods[i].string) { … … 120 120 init.tasks[init.cnt].arguments[0] = 0; 121 121 } 122 122 123 123 init.cnt++; 124 124 } … … 128 128 { 129 129 uint32_t pos = 0; 130 130 131 131 while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) { 132 132 e820table[e820counter] = memmap->mm_info; 133 133 134 134 /* Compute address of next structure. */ 135 135 uint32_t size = sizeof(memmap->size) + memmap->size; 136 136 memmap = (multiboot_memmap_t *) ((uintptr_t) memmap + size); 137 137 pos += size; 138 138 139 139 e820counter++; 140 140 } … … 163 163 multiboot_modules(info->mods_count, 164 164 (multiboot_module_t *) MULTIBOOT_PTR(info->mods_addr)); 165 165 166 166 /* Copy memory map. */ 167 167 if ((info->flags & MULTIBOOT_INFO_FLAGS_MMAP) != 0) -
kernel/genarch/src/multiboot/multiboot2.c
r3061bc1 ra35b458 56 56 multiboot_extract_argument(init.tasks[init.cnt].arguments, 57 57 CONFIG_TASK_ARGUMENTS_BUFLEN, module->string); 58 58 59 59 init.cnt++; 60 60 } … … 66 66 ((uintptr_t) memmap + sizeof(*memmap)); 67 67 uint32_t pos = sizeof(*memmap); 68 68 69 69 while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) { 70 70 e820table[e820counter].base_address = entry->base_address; 71 71 e820table[e820counter].size = entry->size; 72 72 e820table[e820counter].type = entry->type; 73 73 74 74 /* Compute address of next entry. */ 75 75 entry = (multiboot2_memmap_entry_t *) 76 76 ((uintptr_t) entry + memmap->entry_size); 77 77 pos += memmap->entry_size; 78 78 79 79 e820counter++; 80 80 } … … 90 90 bfb_bpp = fbinfo->bpp; 91 91 bfb_scanline = fbinfo->scanline; 92 92 93 93 bfb_red_pos = fbinfo->rgb.red_pos; 94 94 bfb_red_size = fbinfo->rgb.red_size; 95 95 96 96 bfb_green_pos = fbinfo->rgb.green_pos; 97 97 bfb_green_size = fbinfo->rgb.green_size; 98 98 99 99 bfb_blue_pos = fbinfo->rgb.blue_pos; 100 100 bfb_blue_size = fbinfo->rgb.blue_size; … … 116 116 if (signature != MULTIBOOT2_LOADER_MAGIC) 117 117 return; 118 118 119 119 const multiboot2_tag_t *tag = (const multiboot2_tag_t *) 120 120 ALIGN_UP((uintptr_t) info + sizeof(*info), MULTIBOOT2_TAG_ALIGN); 121 121 122 122 while (tag->type != MULTIBOOT2_TAG_TERMINATOR) { 123 123 switch (tag->type) { … … 135 135 break; 136 136 } 137 137 138 138 tag = (const multiboot2_tag_t *) 139 139 ALIGN_UP((uintptr_t) tag + tag->size, MULTIBOOT2_TAG_ALIGN); -
kernel/genarch/src/ofw/ebus.c
r3061bc1 ra35b458 55 55 if (!prop) 56 56 return false; 57 57 58 58 ranges = prop->size / sizeof(ofw_ebus_range_t); 59 59 range = prop->value; 60 60 61 61 unsigned int i; 62 62 63 63 for (i = 0; i < ranges; i++) { 64 64 if (reg->space != range[i].child_space) … … 67 67 range[i].size)) { 68 68 ofw_pci_reg_t pci_reg; 69 69 70 70 pci_reg.space = range[i].parent_space; 71 71 pci_reg.addr = range[i].parent_base + 72 72 (reg->addr - range[i].child_base); 73 73 pci_reg.size = reg->size; 74 74 75 75 return ofw_pci_apply_ranges(node->parent, &pci_reg, pa); 76 76 } … … 86 86 ofw_tree_property_t *prop; 87 87 ofw_tree_node_t *controller; 88 88 89 89 prop = ofw_tree_getprop(node, "interrupt-map"); 90 90 if (!prop || !prop->value) … … 93 93 ofw_ebus_intr_map_t *intr_map = prop->value; 94 94 size_t count = prop->size / sizeof(ofw_ebus_intr_map_t); 95 95 96 96 assert(count); 97 97 98 98 prop = ofw_tree_getprop(node, "interrupt-map-mask"); 99 99 if (!prop || !prop->value) 100 100 return false; 101 101 102 102 ofw_ebus_intr_mask_t *intr_mask = prop->value; 103 103 104 104 assert(prop->size == sizeof(ofw_ebus_intr_mask_t)); 105 105 106 106 uint32_t space = reg->space & intr_mask->space_mask; 107 107 uint32_t addr = reg->addr & intr_mask->addr_mask; 108 108 uint32_t intr = interrupt & intr_mask->intr_mask; 109 109 110 110 unsigned int i; 111 111 for (i = 0; i < count; i++) { … … 127 127 if (!controller) 128 128 return false; 129 129 130 130 if (str_cmp(ofw_tree_node_name(controller), "pci") != 0) { 131 131 /* -
kernel/genarch/src/ofw/ofw_tree.c
r3061bc1 ra35b458 70 70 return &node->property[i]; 71 71 } 72 72 73 73 return NULL; 74 74 } … … 87 87 if ((!prop) || (prop->size < 2)) 88 88 return NULL; 89 89 90 90 return prop->value; 91 91 } … … 110 110 return cur; 111 111 } 112 112 113 113 /* 114 114 * Disambigued name not found. … … 122 122 return cur; 123 123 } 124 124 125 125 return NULL; 126 126 } … … 141 141 ofw_tree_property_t *prop = 142 142 ofw_tree_getprop(cur, "device_type"); 143 143 144 144 if ((!prop) || (!prop->value)) 145 145 continue; 146 146 147 147 if (str_cmp(prop->value, dtype) == 0) 148 148 return cur; 149 149 } 150 150 151 151 return NULL; 152 152 } … … 170 170 if (cur->node_handle == handle) 171 171 return cur; 172 172 173 173 if (cur->child) { 174 174 ofw_tree_node_t *node = … … 178 178 } 179 179 } 180 180 181 181 return NULL; 182 182 } … … 197 197 ofw_tree_property_t *prop = 198 198 ofw_tree_getprop(cur, "device_type"); 199 199 200 200 if ((!prop) || (!prop->value)) 201 201 continue; 202 202 203 203 if (str_cmp(prop->value, dtype) == 0) 204 204 return cur; 205 205 } 206 206 207 207 return NULL; 208 208 } … … 223 223 ofw_tree_property_t *prop = 224 224 ofw_tree_getprop(cur, "name"); 225 225 226 226 if ((!prop) || (!prop->value)) 227 227 continue; 228 228 229 229 if (str_cmp(prop->value, name) == 0) 230 230 return cur; 231 231 } 232 232 233 233 return NULL; 234 234 } … … 246 246 if (path[0] != '/') 247 247 return NULL; 248 248 249 249 ofw_tree_node_t *node = ofw_root; 250 250 size_t j; 251 251 252 252 for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) { 253 253 for (j = i; (j < str_size(path)) && (path[j] != '/'); j++); 254 254 255 255 /* Skip extra slashes */ 256 256 if (i == j) 257 257 continue; 258 258 259 259 char buf[NAME_BUF_LEN + 1]; 260 260 memcpy(buf, &path[i], j - i); … … 262 262 node = ofw_tree_find_child(node, buf); 263 263 } 264 264 265 265 return node; 266 266 } … … 285 285 ofw_tree_property_t *prop = 286 286 ofw_tree_getprop(cur, "device_type"); 287 287 288 288 if ((prop) && (prop->value) && (str_cmp(prop->value, dtype) == 0)) { 289 289 bool ret = walker(cur, arg); … … 291 291 return false; 292 292 } 293 293 294 294 if (cur->child) { 295 295 bool ret = … … 299 299 } 300 300 } 301 301 302 302 return true; 303 303 } … … 336 336 { 337 337 ofw_tree_node_t *node = (ofw_tree_node_t *) data; 338 338 339 339 /* Compute serialized data size */ 340 340 *size = 0; … … 342 342 *size += str_size(node->property[i].name) + 1 + 343 343 sizeof(node->property[i].size) + node->property[i].size; 344 344 345 345 if (dry_run) 346 346 return NULL; 347 347 348 348 void *dump = malloc(*size, FRAME_ATOMIC); 349 349 if (dump == NULL) { … … 351 351 return NULL; 352 352 } 353 353 354 354 /* Serialize the data */ 355 355 size_t pos = 0; … … 358 358 str_cpy(dump + pos, *size - pos, node->property[i].name); 359 359 pos += str_size(node->property[i].name) + 1; 360 360 361 361 /* Value size */ 362 362 memcpy(dump + pos, &node->property[i].size, 363 363 sizeof(node->property[i].size)); 364 364 pos += sizeof(node->property[i].size); 365 365 366 366 /* Value */ 367 367 memcpy(dump + pos, node->property[i].value, … … 369 369 pos += node->property[i].size; 370 370 } 371 371 372 372 return ((void *) dump); 373 373 } … … 385 385 { 386 386 char *cur_path = (char *) malloc(PATH_MAX_LEN, 0); 387 387 388 388 for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) { 389 389 if ((cur->parent) && (path)) … … 391 391 else 392 392 snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name); 393 393 394 394 sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties, 395 395 (void *) cur); 396 396 397 397 if (cur->child) 398 398 ofw_tree_node_sysinfo(cur->child, cur_path); 399 399 } 400 400 401 401 free(cur_path); 402 402 } -
kernel/genarch/src/ofw/pci.c
r3061bc1 ra35b458 63 63 return false; 64 64 } 65 65 66 66 ranges = prop->size / sizeof(ofw_pci_range_t); 67 67 range = prop->value; 68 68 69 69 unsigned int i; 70 70 71 71 for (i = 0; i < ranges; i++) { 72 72 if ((reg->space & PCI_SPACE_MASK) != … … 95 95 return true; 96 96 } 97 97 98 98 ofw_tree_property_t *prop; 99 99 ofw_pci_reg_t *assigned_address; 100 100 size_t assigned_addresses; 101 101 102 102 prop = ofw_tree_getprop(node, "assigned-addresses"); 103 103 if (!prop) 104 104 panic("Cannot find 'assigned-addresses' property."); 105 105 106 106 assigned_addresses = prop->size / sizeof(ofw_pci_reg_t); 107 107 assigned_address = prop->value; 108 108 109 109 unsigned int i; 110 110 111 111 for (i = 0; i < assigned_addresses; i++) { 112 112 if ((assigned_address[i].space & PCI_REG_MASK) == … … 118 118 } 119 119 } 120 120 121 121 return false; 122 122 } -
kernel/genarch/src/ofw/sbus.c
r3061bc1 ra35b458 46 46 ofw_sbus_range_t *range; 47 47 size_t ranges; 48 48 49 49 /* 50 50 * The SBUS support is very rudimentary in that we simply assume … … 55 55 if (!node->parent || node->parent->parent) 56 56 return false; 57 57 58 58 prop = ofw_tree_getprop(node, "ranges"); 59 59 if (!prop) 60 60 return false; 61 61 62 62 ranges = prop->size / sizeof(ofw_sbus_range_t); 63 63 range = prop->value; 64 64 65 65 unsigned int i; 66 66 67 67 for (i = 0; i < ranges; i++) { 68 68 if (overlaps(reg->addr, reg->size, range[i].child_base, … … 73 73 } 74 74 } 75 75 76 76 return false; 77 77 } -
kernel/genarch/src/softint/division.c
r3061bc1 ra35b458 43 43 unsigned int result; 44 44 int steps = sizeof(unsigned int) * 8; 45 45 46 46 *remainder = 0; 47 47 result = 0; 48 48 49 49 if (b == 0) { 50 50 /* FIXME: division by zero */ 51 51 return 0; 52 52 } 53 53 54 54 if (a < b) { 55 55 *remainder = a; 56 56 return 0; 57 57 } 58 58 59 59 for (; steps > 0; steps--) { 60 60 /* shift one bit to remainder */ 61 61 *remainder = ((*remainder) << 1) | (( a >> 31) & 0x1); 62 62 result <<= 1; 63 63 64 64 if (*remainder >= b) { 65 65 *remainder -= b; … … 68 68 a <<= 1; 69 69 } 70 70 71 71 return result; 72 72 } … … 77 77 unsigned long long result; 78 78 int steps = sizeof(unsigned long long) * 8; 79 79 80 80 *remainder = 0; 81 81 result = 0; 82 82 83 83 if (b == 0) { 84 84 /* FIXME: division by zero */ 85 85 return 0; 86 86 } 87 87 88 88 if (a < b) { 89 89 *remainder = a; 90 90 return 0; 91 91 } 92 92 93 93 for (; steps > 0; steps--) { 94 94 /* shift one bit to remainder */ 95 95 *remainder = ((*remainder) << 1) | ((a >> 63) & 0x1); 96 96 result <<= 1; 97 97 98 98 if (*remainder >= b) { 99 99 *remainder -= b; … … 102 102 a <<= 1; 103 103 } 104 104 105 105 return result; 106 106 } … … 111 111 unsigned int rem; 112 112 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 113 113 114 114 if (SGN(a) == SGN(b)) 115 115 return result; 116 116 117 117 return -result; 118 118 } … … 123 123 unsigned long long rem; 124 124 long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem); 125 125 126 126 if (SGN(a) == SGN(b)) 127 127 return result; 128 128 129 129 return -result; 130 130 } … … 149 149 unsigned int rem; 150 150 divandmod32(a, b, &rem); 151 151 152 152 /* if divident is negative, remainder must be too */ 153 153 if (!(SGN(a))) 154 154 return -((int) rem); 155 155 156 156 return (int) rem; 157 157 } … … 162 162 unsigned long long rem; 163 163 divandmod64(a, b, &rem); 164 164 165 165 /* if divident is negative, remainder must be too */ 166 166 if (!(SGN(a))) 167 167 return -((long long) rem); 168 168 169 169 return (long long) rem; 170 170 } … … 190 190 unsigned int rem; 191 191 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 192 192 193 193 if (SGN(a) == SGN(b)) { 194 194 *c = rem; 195 195 return result; 196 196 } 197 197 198 198 *c = -rem; 199 199 return -result; … … 210 210 unsigned long long rem; 211 211 long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem); 212 212 213 213 if (SGN(a) == SGN(b)) { 214 214 *c = rem; 215 215 return result; 216 216 } 217 217 218 218 *c = -rem; 219 219 return -result; -
kernel/genarch/src/srln/srln.c
r3061bc1 ra35b458 53 53 bool cr = false; 54 54 uint32_t escape = 0; 55 55 56 56 while (true) { 57 57 wchar_t ch = indev_pop_character(&instance->raw); 58 58 59 59 /* ANSI escape sequence processing */ 60 60 if (escape != 0) { 61 61 escape <<= 8; 62 62 escape |= ch & 0xff; 63 63 64 64 if ((escape == 0x1b4f) || (escape == 0x1b5b) || (escape == 0x1b5b33)) 65 65 continue; 66 66 67 67 switch (escape) { 68 68 case 0x1b4f46: … … 100 100 } 101 101 } 102 102 103 103 if (ch == 0x1b) { 104 104 escape = ch & 0xff; 105 105 continue; 106 106 } 107 107 108 108 /* Replace carriage return with line feed 109 109 and suppress any following line feed */ … … 112 112 continue; 113 113 } 114 114 115 115 if (ch == '\r') { 116 116 ch = '\n'; … … 118 118 } else 119 119 cr = false; 120 120 121 121 /* Backspace */ 122 122 if (ch == 0x7f) 123 123 ch = '\b'; 124 124 125 125 indev_push_character(instance->sink, ch); 126 126 } … … 134 134 instance->thread = thread_create(ksrln, (void *) instance, 135 135 TASK, THREAD_FLAG_NONE, "ksrln"); 136 136 137 137 if (!instance->thread) { 138 138 free(instance); 139 139 return NULL; 140 140 } 141 141 142 142 instance->sink = NULL; 143 143 indev_initialize("srln", &instance->raw, &srln_raw_ops); 144 144 } 145 145 146 146 return instance; 147 147 } … … 151 151 assert(instance); 152 152 assert(sink); 153 153 154 154 instance->sink = sink; 155 155 thread_ready(instance->thread); 156 156 157 157 return &instance->raw; 158 158 }
Note:
See TracChangeset
for help on using the changeset viewer.