~ubuntu-branches/ubuntu/saucy/seabios/saucy-proposed

« back to all changes in this revision

Viewing changes to src/util.h

  • Committer: Bazaar Package Importer
  • Author(s): Vagrant Cascadian
  • Date: 2010-11-26 17:54:44 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101126175444-rpdeja25wf6fjycx
Tags: 0.6.1.2-1
* New upstream version from git tag. 
  - Fixes virtio-blk failure after reboot (Closes: #604735).
* Update debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
#define htons(x) __htons_constant(x)
111
111
#define ntohs(x) htons(x)
112
112
 
 
113
static inline u16 cpu_to_le16(u16 x)
 
114
{
 
115
    return x;
 
116
}
 
117
 
 
118
static inline u32 cpu_to_le32(u32 x)
 
119
{
 
120
    return x;
 
121
}
 
122
 
113
123
static inline u32 getesp(void) {
114
124
    u32 esp;
115
125
    asm("movl %%esp, %0" : "=rm"(esp));
152
162
            : "ebx", "edx", "esi", "edi", "cc", "memory");              \
153
163
    } while (0)
154
164
 
155
 
// GDT bit manipulation
 
165
// GDT bits
 
166
#define GDT_CODE     (0x9bULL << 40) // Code segment - P,R,A bits also set
 
167
#define GDT_DATA     (0x93ULL << 40) // Data segment - W,A bits also set
 
168
#define GDT_B        (0x1ULL << 54)  // Big flag
 
169
#define GDT_G        (0x1ULL << 55)  // Granularity flag
 
170
// GDT bits for segment base
156
171
#define GDT_BASE(v)  ((((u64)(v) & 0xff000000) << 32)           \
157
172
                      | (((u64)(v) & 0x00ffffff) << 16))
 
173
// GDT bits for segment limit (0-1Meg)
158
174
#define GDT_LIMIT(v) ((((u64)(v) & 0x000f0000) << 32)   \
159
175
                      | (((u64)(v) & 0x0000ffff) << 0))
160
 
#define GDT_CODE     (0x9bULL << 40) // Code segment - P,R,A bits also set
161
 
#define GDT_DATA     (0x93ULL << 40) // Data segment - W,A bits also set
162
 
#define GDT_B        (0x1ULL << 54)  // Big flag
163
 
#define GDT_G        (0x1ULL << 55)  // Granularity flag
 
176
// GDT bits for segment limit (0-4Gig in 4K chunks)
 
177
#define GDT_GRANLIMIT(v) (GDT_G | GDT_LIMIT((v) >> 12))
164
178
 
165
179
struct descloc_s {
166
180
    u16 length;
322
336
// shadow.c
323
337
void make_bios_writable(void);
324
338
void make_bios_readonly(void);
 
339
void make_bios_writable_intel(u16 bdf, u32 pam0);
 
340
void make_bios_readonly_intel(u16 bdf, u32 pam0);
 
341
 
 
342
// smm.c
 
343
void smm_save_and_copy(void);
 
344
void smm_relocate_and_restore(void);
325
345
 
326
346
// pciinit.c
327
347
extern const u8 pci_irqs[4];
363
383
 
364
384
// bootsplash.c
365
385
void enable_vga_console(void);
 
386
void enable_bootsplash(void);
366
387
void disable_bootsplash(void);
367
388
 
368
389
// resume.c
394
415
static inline void *malloc_fseg(u32 size) {
395
416
    return pmm_malloc(&ZoneFSeg, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN);
396
417
}
 
418
static inline void *malloc_tmplow(u32 size) {
 
419
    return pmm_malloc(&ZoneTmpLow, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN);
 
420
}
397
421
static inline void *malloc_tmphigh(u32 size) {
398
422
    return pmm_malloc(&ZoneTmpHigh, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN);
399
423
}
401
425
    void *ret = malloc_tmphigh(size);
402
426
    if (ret)
403
427
        return ret;
404
 
    return pmm_malloc(&ZoneTmpLow, PMM_DEFAULT_HANDLE, size, MALLOC_MIN_ALIGN);
 
428
    return malloc_tmplow(size);
405
429
}
406
430
static inline void *memalign_low(u32 align, u32 size) {
407
431
    return pmm_malloc(&ZoneLow, PMM_DEFAULT_HANDLE, size, align);